PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms System.Reflection.ReflectionTypeLoadException in Windows Service

Reply

System.Reflection.ReflectionTypeLoadException in Windows Service

 
Thread Tools Rate Thread
Old 10-02-2006, 05:38 PM   #1
=?Utf-8?B?WmFjaA==?=
Guest
 
Posts: n/a
Default System.Reflection.ReflectionTypeLoadException in Windows Service


Hello!

I'm experiencing this exception while attempting to examine the public types
on my assembly DLL. Here is the code:

Dim objType As Type
Dim objDLL As Assembly

objDLL = System.Reflection.Assembly.LoadFrom(pathToDLL)

For each objType in objDLL.GetTypes <---- Exception is raised from GetTypes
.... stuff
Next

The same code executes without a problem from a windows forms application,
but not this Windows Service. When I examine the loaderexceptions property,
it contains 1 System.TypeLoadException that simply states "Could not load
type {myType} from Assembly {myAssembly}" etc. The Types array contains 1
RunTime type that contains a reference to a windows form that is a public
member of my Assembly - which is why I bring the question to you. Is there a
problem in general with loading windows forms types from an assembly while
running within a Windows Service, or is there just some sort of dependency
that isn't loading?

Thanks for any assistance!

Zach




  Reply With Quote
Old 13-02-2006, 12:42 PM   #2
Dmytro Lapshyn [MVP]
Guest
 
Posts: n/a
Default Re: System.Reflection.ReflectionTypeLoadException in Windows Service

Hello Zach,

> it contains 1 System.TypeLoadException that simply states "Could not load
> type {myType} from Assembly {myAssembly}" etc. The Types array contains 1
> RunTime type that contains a reference to a windows form that is a public
> member of my Assembly - which is why I bring the question to you.


Actually, this might be a problem, if one of those Windows Form types
contain a static constructor, and this constructor, in turn, attempts some
interaction with the desktop. You might want to examine the InnerException
property of the TypeLoadException you get - it might indicate the real
underlying problem.

"Zach" <Zach@discussions.microsoft.com> wrote in message
news:10CEB384-7BA2-44C4-8146-9384CE13A170@microsoft.com...
> Hello!
>
> I'm experiencing this exception while attempting to examine the public
> types
> on my assembly DLL. Here is the code:
>
> Dim objType As Type
> Dim objDLL As Assembly
>
> objDLL = System.Reflection.Assembly.LoadFrom(pathToDLL)
>
> For each objType in objDLL.GetTypes <---- Exception is raised from
> GetTypes
> .... stuff
> Next
>
> The same code executes without a problem from a windows forms application,
> but not this Windows Service. When I examine the loaderexceptions
> property,
> it contains 1 System.TypeLoadException that simply states "Could not load
> type {myType} from Assembly {myAssembly}" etc. The Types array contains 1
> RunTime type that contains a reference to a windows form that is a public
> member of my Assembly - which is why I bring the question to you. Is
> there a
> problem in general with loading windows forms types from an assembly while
> running within a Windows Service, or is there just some sort of dependency
> that isn't loading?
>
> Thanks for any assistance!
>
> Zach
>
>
>
>



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off