PC Review


Reply
Thread Tools Rate Thread

Cannot use class library - TypeLoadException

 
 
Michael
Guest
Posts: n/a
 
      20th Dec 2004
Hi,

I'm having a problem with running an application that uses an assembly
I created, when run in the emulator.

The assembly uses XmlTextReader. Then calling the assembly's
constructor in the application, I get a TypeLoadException(). If I move
the XmlTextReader to the application, it works.

Additionally, if I call the XmlTextReader in the application before
calling the assembly's constructor (which contains the XmlTextReader),
it will work fine.

Lastly, if I load the XML assembly in the application, everything works
fine (Assembly a =
Assembly.LoadFrom(@"\Windows\GAC_System.Xml_v1_0_5000_0_cneutral_1.dll").

It seems that my application can't load the System.Xml assembly from my
class library unless the application uses XmlTextReader first.

To repro, I created a new smart device project. Then I add a class
library to the solution. The library looks like this:

using System;
using System.Reflection;
using System.Xml;

namespace SmartDeviceApplication2
{
public class Class1
{
public Class1()
{
XmlDocument doc = new XmlDocument();

XmlTextReader reader = null;
if (reader == null)
return;
}
}
}

The only changes made to the application is:

private void Form1_Load(object sender, System.EventArgs e)
{
Class1 c = new Class1();
}


Can anyone help me???

 
Reply With Quote
 
 
 
 
Ilya Tumanov [MS]
Guest
Posts: n/a
 
      21st Dec 2004
This library, it's compiled for CF or desktop?

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> From: "Michael" <(E-Mail Removed)>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> Subject: Cannot use class library - TypeLoadException
> Date: 20 Dec 2004 11:15:18 -0800
> Organization: http://groups.google.com
> Lines: 52
> Message-ID: <(E-Mail Removed)>
> NNTP-Posting-Host: 12.216.128.93
> Mime-Version: 1.0
> Content-Type: text/plain; charset="iso-8859-1"
> X-Trace: posting.google.com 1103570122 8038 127.0.0.1 (20 Dec 2004

19:15:22 GMT)
> X-Complaints-To: groups-(E-Mail Removed)
> NNTP-Posting-Date: Mon, 20 Dec 2004 19:15:22 +0000 (UTC)
> User-Agent: G2/0.2
> Complaints-To: groups-(E-Mail Removed)
> Injection-Info: z14g2000cwz.googlegroups.com; posting-host=12.216.128.93;
> posting-account=uFQ1qg0AAAAxyEkxdLMi6kloEvCupsZQ
> Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwi
x.com!newsfeed.cwix.com!news.maxwell.syr.edu!postnews.google.com!z14g2000cwz
.googlegroups.com!not-for-mail
> Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.framework.compactframework:67265
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
>
> Hi,
>
> I'm having a problem with running an application that uses an assembly
> I created, when run in the emulator.
>
> The assembly uses XmlTextReader. Then calling the assembly's
> constructor in the application, I get a TypeLoadException(). If I move
> the XmlTextReader to the application, it works.
>
> Additionally, if I call the XmlTextReader in the application before
> calling the assembly's constructor (which contains the XmlTextReader),
> it will work fine.
>
> Lastly, if I load the XML assembly in the application, everything works
> fine (Assembly a =
>

Assembly.LoadFrom(@"\Windows\GAC_System.Xml_v1_0_5000_0_cneutral_1.dll").
>
> It seems that my application can't load the System.Xml assembly from my
> class library unless the application uses XmlTextReader first.
>
> To repro, I created a new smart device project. Then I add a class
> library to the solution. The library looks like this:
>
> using System;
> using System.Reflection;
> using System.Xml;
>
> namespace SmartDeviceApplication2
> {
> public class Class1
> {
> public Class1()
> {
> XmlDocument doc = new XmlDocument();
>
> XmlTextReader reader = null;
> if (reader == null)
> return;
> }
> }
> }
>
> The only changes made to the application is:
>
> private void Form1_Load(object sender, System.EventArgs e)
> {
> Class1 c = new Class1();
> }
>
>
> Can anyone help me???
>
>


 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      21st Dec 2004
Thanks so much!

Duh! After being puzzled at what you meant, I searched groups.google
again and found out that under the "Smart Device Application" wizard,
there is an option to create a Smart Device Class Library. That isn't
very obvious on Microsoft's part.

So my next question is, can I have both a class library for .net and
..net cf?

 
Reply With Quote
 
Daniel Moth
Guest
Posts: n/a
 
      21st Dec 2004
If you create it for CF then it is retargetable to the desktop (not the
other way round):
http://www.danielmoth.com/Blog/2004/...table-256.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


"Michael" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks so much!
>
> Duh! After being puzzled at what you meant, I searched groups.google
> again and found out that under the "Smart Device Application" wizard,
> there is an option to create a Smart Device Class Library. That isn't
> very obvious on Microsoft's part.
>
> So my next question is, can I have both a class library for .net and
> .net cf?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic How To Question: Class Library or Windows Control Library eBob.com Microsoft VB .NET 3 20th Feb 2006 08:12 PM
Class Library in CF vs Windows Class Library TechGladiator Microsoft Dot NET Compact Framework 3 27th Jan 2006 12:55 AM
Re: Difference between Web Control Library and Class Library Alan Ferrandiz [MCT] Microsoft ASP .NET 0 11th Sep 2004 02:51 PM
Re: Difference between Web Control Library and Class Library Mythran Microsoft ASP .NET 0 24th Aug 2004 06:53 PM
Big Faceless PDF Library 2.2.3 - A Java class library for importing and creating PDF documents. Gordon Darling Freeware 0 13th Jul 2004 09:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 PM.