ReflectionTypeLoadException with service installer

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I created a windows service and added an installer by following the tutorial
in MSDN. But when I run the installutil.exe tool I get an error. Below is
the log.

Installing assembly 'c:\temp\serv\prorec.exe'.
Affected parameters are:
assemblypath = c:\temp\serv\prorec.exe
logfile = c:\temp\serv\prorec.InstallLog
An exception occurred while trying to find the installers in the
c:\temp\serv\prorec.exe assembly.
System.Reflection.ReflectionTypeLoadException: One or more of the types in
the assembly unable to load.
Aborting installation for c:\temp\serv\prorec.exe.
Rolling back assembly 'c:\temp\serv\prorec.exe'.
Affected parameters are:
assemblypath = c:\temp\serv\prorec.exe
logfile = c:\temp\serv\prorec.InstallLog
An exception occurred while trying to find the installers in the
c:\temp\serv\prorec.exe assembly.
System.Reflection.ReflectionTypeLoadException: One or more of the types in
the assembly unable to load.
Aborting installation for c:\temp\serv\prorec.exe.

If I change the Main() function to create my service class and call the
start & stop manually it runs fine as an application. Can anyone tell me
how to find out what the problem is? Is there anyway to get a better
description of what type could not be loaded?



Bob
 
I was getting this error because I had the below structure in my project.
Once I removed the strucutre it started working. It would be nice if the
error log created by the installutil actually had some useful information in
it. I still don't no why removing this structure fixed the problem. It
works when I run it as an application.

[StructLayout(LayoutKind.Explicit, Size=318)]
struct MSGRECORD
{
[FieldOffset(0)]
public long nFlag;
[FieldOffset(4)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst=50)]
public string szUID;
[FieldOffset(54)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst=260)]
public string szData;
[FieldOffset(314)]
public long Created;
} ;
 
Back
Top