Cannot use class library - TypeLoadException

M

Michael

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???
 
I

Ilya Tumanov [MS]

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.
--------------------
 
M

Michael

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top