Hi,

I have written a C# application which uses Tao Framework bindings for OpenGL and FreeGlut.
It references two assemblies (Tao.OpenGL and Tao.Freeglut) and also requires that the appropriate OpenGL and Freeglut dlls be somewhere in the system.

How can I publish this application in such a way that the user simply installs it without worrying about any of these dependencies?

As long as the DLL's are located in the same folder as the executables it should work without any issues.

No joy. It doesn't even work on my own computer when I run the install, and I already have all the necessary dlls.

Where are the DLL's stored, are they included in the installer? Or are they just somewhere on the computer? Because libraries are looked for in the folder with the executable or in any folders defined by the Path environment variable.

So what is your question exactly? And what errors are you seeing when you attempt to run your application?

Where are the DLL's stored, are they included in the installer? Or are they just somewhere on the computer? Because libraries are looked for in the folder with the executable or in any folders defined by the Path environment variable.

Thanks for replying,

I am using two external .NET assemblies (Tao.OpenGl and Tao.FreeGlut). These are included in the project and I can see them in the "publish" settings. When I publish the project they also appear as .dll.deploy files.

But they are just wrappers for the actual OpenGl and FreeGlut dlls which are located in WINDOWS/system32.

So what is your question exactly? And what errors are you seeing when you attempt to run your application?

Hi, thanks for replying.
Sorry if I wasn't being clear enough.

When I publish and run the application it just says "Application has stopped working" even though it works fine from within Visual Studio.

I need to be able to give this application to people in a "human form", without them having to download and compile their own versions of FreeGlut and without them having to run it from within Visual Studio.

My question is what do I need to do so that an end-user on a random Windows computer can simply double click some icon and everything will work fine?

You need to deploy the OpenGl and FreeGlut dlls with your installation media. The static scanning of a deployment project will not catch dynamically linked libraries, which is likely the case here, so just manually add those DLLs to your installer output. If your application crashes before the Application.Run() is called you can catch the exception text in stdout/stderr.

For example this application:

using System;
using System.Windows.Forms;

namespace daniweb
{

  static class Program
  {
    private enum SW
    {
      SW_HIDE = 0,
      SW_SHOWNORMAL = 1
    }
    //Notice the DLL name
    [System.Runtime.InteropServices.DllImport("shell32123123.dll")]
    private static extern long ShellExecute(Int32 hWnd, string lpOperation,
    string lpFile, string lpParameters, string lpDirectory, long nShowCmd);

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
      Application.EnableVisualStyles();
      Application.SetCompatibleTextRenderingDefault(false);
      ShellExecute(0, "open", "notepad.exe", null, null, (long)SW.SW_SHOWNORMAL);
      Application.Run(new frmContactModel());
      //Application.Run(new frmProcess());
    }

The DLL name was changed so it wouldn't be found resulting in the application crashing before .Run() was called thus you can't do anything to handle the error. To find the error text:

C:\DOTNET~1\daniweb\bin\Debug>daniweb.exe >> crashlog.txt 2>&1

C:\DOTNET~1\daniweb\bin\Debug>edit crashlog.txt

File contents:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'shell32123123.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at daniweb.Program.ShellExecute(Int32 hWnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory, Int64 nShowCmd)
   at daniweb.Program.Main() in C:\dotnetwin\daniweb\Program.cs:line 28

Thanks you, that makes sense.

I tried adding the Tao dlls in my publish settings and I can see them created in my resulting publish directory. So I think they are being deployed properly.

But it still doesn't work. Do I need to deploy the native dlls as well? I can't add them in my publish settings because it tells me they are not .NET assemblies.

This is a desktop application we're talking about here and not an ASP.NET web app, right? If so then why are you using the publish option instead of creating a Deployment project? Author a deployment project and have the native DLLs deployed in the project directory. If you really want to continue using the publish style of deployment you should author your own publisher with MSBuild

This is a desktop application we're talking about here and not an ASP.NET web app, right? If so then why are you using the publish option instead of creating a Deployment project? Author a deployment project and have the native DLLs deployed in the project directory. If you really want to continue using the publish style of deployment you should author your own publisher with MSBuild

OK great, I didn't know any of that. Yes it is a desktop app and I'm using publish.

Thanks a lot, I am looking into deployment projects now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.