Skip to main content
gamedev.net
🔒 Locked

System.TypeLoadException

Started by Hermes 0 replies 900+ views
Original Post
Hermes
Hermes
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 !

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.