System.TypeLoadException

Started by
0 comments, last by GameDev.net 17 years, 6 months ago
Hi, Since i didn't find any relevant information about C++ win32 services, i put the core functions(C/C++ based) into a DLL and loaded them in a C# service. Here is the error i get when i try to start the service. "An unhandled exception of type 'System.TypeLoadException' occurred in Unknown Module. ............................................................. because the method InitServiceWrapper has no RVA. " I really don't know how to get arround this. Below is the C++ function i try to call from my service. It is supposed to load a driver


void InitService()
{

    //
    // open the device
    //
    
    if((hDevice = CreateFile( "\\\\.\\DRV",
            GENERIC_READ | GENERIC_WRITE,
            0,
            NULL,
            CREATE_ALWAYS,
            FILE_ATTRIBUTE_NORMAL,
            NULL)) == INVALID_HANDLE_VALUE) {
                
        errNum = GetLastError();

        if (errNum != ERROR_FILE_NOT_FOUND) {

            printf("CreateFile failed!  ERROR_FILE_NOT_FOUND = %d\n", errNum);

            return ;
        }
       
        //
        // The driver is not started yet so let us the install the driver.
        // First setup full path to driver name.
        //

        if (!SetupDriverName(driverLocation)) {

            return ;
        }
        
        if (!ManageDriver(PARANOID_DEVICE_NAME,
                          (LPCSTR)driverLocation,
                          DRIVER_FUNC_INSTALL
                          )) {

            printf("Unable to install driver. \n");

            //
            // Error - remove driver.
            //

            ManageDriver(PARANOID_DEVICE_NAME,
                         (LPCSTR)driverLocation,
                         DRIVER_FUNC_REMOVE
                         );
            
            return;
        }
        
        

   		
			
  }
 
}



Thanks !
Advertisement
Hermes,
i think you posted the wrong snippet of code here. The error is likely to be found in the InitServiceWrapper() method. The border line between managed an unmanaged implementation is of interest here. Please post some more of the "plumbing" code.

cheers,
simon

This topic is closed to new replies.

Advertisement