C# Express Deploying Application

This is a discussion on C# Express Deploying Application within the C# Programming forums, part of the General Programming Boards category; Hello All, I have created an application using Visual C# Express that talk to a Visual C++ Express DLL file ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    52

    C# Express Deploying Application

    Hello All,

    I have created an application using Visual C# Express that talk to a Visual C++ Express DLL file that I created. The application runs just fine on two computers, one running windows 7 and one running windows xp. Both computer have visual c# and visual c++ express editions installed.

    The problem is when I try to run the application in a computer that doesn't have visual c# or visual c++ installed. The application form comes up but when I try to run it it doesn't find the DLL file. I have installed .NET 4.0 on the pc I'm trying to run it already.

    What I did was just copy the files from the bin/release folder of C# and moved then to the PC I wanted the application to run at. I also tried to copy the DLL file to the release folder with no luck. It doesn't find the DLL file.

    I hope someone can give me advice on this.
    Thanks.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Maybe it looks at a absolute path, so when you move the DLL it doesn't find that path. Not an expert with the linking of DLL to assist further.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    You will need the C++ runtime installed on the other PC. Does a normal executable created with C++ on your PC run on the target machine?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    So I'm still having problems. I will state the problem I'm having again:

    I made a GUI with C# that talks to a DLL made with C++. The Applications made in C# runs just fine on ANY computer that has Visual C++ Express 2010 installed on it. If the host machine doesn't have C++ installed a dllexeption error comes up stating that it can't find the DLL file I made with C++.

    Here is the error reported from C# when trying to run the Application from a machine w/o C++ installed. The host machine has .NET Framework 4.0 installed and Microsoft Visual C++ 2008 Redistributable Package installed, any help will be appreciated.

    Code:
    System.DllNotFoundException was unhandled
      Message=Unable to load DLL 'uni_1-Wire_ProgrammerDLL.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
      Source=uni_1-Wire_Programmer
      TypeName=""
      StackTrace:
           at uni_1_Wire_Programmer.Form1.InitComPort1()
           at uni_1_Wire_Programmer.Form1.SearchDevice() in C:\Documents and Settings\User\Desktop\1-Wire\uni_1-Wire_Programmer\uni_1-Wire_Programmer\Form1.cs:line 108
           at uni_1_Wire_Programmer.Form1..ctor() in C:\Documents and Settings\User\Desktop\1-Wire\uni_1-Wire_Programmer\uni_1-Wire_Programmer\Form1.cs:line 38
           at uni_1_Wire_Programmer.Program.Main(String[] args) in C:\Documents and Settings\User\Desktop\1-Wire\uni_1-Wire_Programmer\uni_1-Wire_Programmer\Program.cs:line 19
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
           at System.Activator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    329
    Show the code that calls the dll file.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    Below is the code in the C# project that calls the .dd InitComPort1() Function.

    Code:
            [DllImport("uni_1-Wire_ProgrammerDLL.dll")]
                       public static extern int InitComPort1();

  7. #7
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    Well, seeing as you're running VS 2010, maybe you should try installing the VC++ 2010 redistributable instead of the 2008 one?

  8. #8
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    I just finished doing that and it didn't help

  9. #9
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Did you try putting an absolute path to the DLL? Maybe it's a "current working directory" issue.
    Last edited by itsme86; 03-25-2011 at 02:07 PM.
    If you understand what you're doing, you're not learning anything.

  10. #10
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    Or, did you compile the C++ DLL in debug mode, rather than release? The redistributable does not provide debug versions of the VC runtime.

  11. #11
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Try setting "project->properties->build->platform target" to x86 in the C# program, rather than Any CPU.

  12. #12
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    So I think I found the problem.
    I used dependency walker and the file msvcr100d.dll was missing in the system32 folder. I copied the file into the folder and the program started working right away. What is the purpose of this DLL and can it be installed with one of the C++ run times?

  13. #13
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    It's the debug runtime (like r2r suspected). Compile your application in release mode and it will use the release runtime that can be installed with the aforementioned redistributable.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  14. #14
    Registered User
    Join Date
    Nov 2009
    Posts
    52
    Ok thanks. Now I'm having a different issue.
    In debug mode the DLL program compiles without any problems, but when I try to compile in release mode it gives me errors:

    Code:
    1>uni_1-Wire_Programmer.cpp(2828): error C2664: 'CreateFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>uni_1-Wire_Programmer.cpp(2837): error C2664: 'CreateEventW' : cannot convert parameter 4 from 'char [80]' to 'LPCWSTR'
    1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>uni_1-Wire_Programmer.cpp(2839): error C2664: 'CreateEventW' : cannot convert parameter 4 from 'char [80]' to 'LPCWSTR'
    The error is somewhere in here:

    Code:
    int OpenCOM(char *port_zstr)
    {
       char tempstr[80];
       short fRetVal;
       COMMTIMEOUTS CommTimeOuts;
       DCB dcb;
    
       // open COMM device
       if ((ComID =
          CreateFile( port_zstr, GENERIC_READ | GENERIC_WRITE,
                      0,
                      NULL,                 // no security attrs
                      OPEN_EXISTING,
                      FILE_FLAG_OVERLAPPED, // overlapped I/O
                      NULL )) == (HANDLE) -1 ) 
       {
          ComID = 0;
          return FALSE;
       }
       else
       {
          // create events for detection of reading and write to com port
          sprintf(tempstr,"COMM_READ_OVERLAPPED_EVENT_FOR_%s",port_zstr);
          osRead.hEvent = CreateEvent(NULL,TRUE,FALSE,tempstr);
          printf(tempstr,"COMM_WRITE_OVERLAPPED_EVENT_FOR_%s",port_zstr);
          osWrite.hEvent = CreateEvent(NULL,TRUE,FALSE,tempstr);

  15. #15
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    Change your C++ project settings' character set option to "Not Set" instead of Unicode.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket programming in C on windows 7
    By wahla in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-27-2010, 08:59 AM
  2. Replies: 0
    Last Post: 11-22-2009, 10:23 AM
  3. Deploying C Application: Help!
    By Nedhue in forum C Programming
    Replies: 5
    Last Post: 02-03-2008, 04:30 AM
  4. [Tutorial] Deploying VC++ 2005 Express Apps
    By psychopath in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-03-2007, 05:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21