I have added a reference to dll file in VS 2008. Yet I still get an error. Not sure why, do I have to do some other changes to get it to work?

Dani AI

Generated

A few practical follow-ups based on 's prompt about whether a DLL is a .NET assembly, and to help others who hit the same error after adding a DLL reference (as happened in this thread with ).

Common causes and quick checks

  • Confirm managed vs unmanaged: managed assemblies can be opened with ILDasm or inspected at runtime; unmanaged/native DLLs are not addable as a .NET reference.
  • If the DLL is native: use P/Invoke (DllImport), a C++/CLI wrapper, or register/import the COM type library for COM DLLs.
  • Architecture mismatch: a 32-bit native/managed DLL will fail in a 64-bit process (BadImageFormatException). Match project Platform target (x86/x64/AnyCPU).
  • Missing dependencies: a dependency of that DLL can cause load failures — use Dependency Walker or the modern "Dependencies" tool.
  • File blocks and protection: downloaded DLLs can be blocked by Windows (Properties -> Unblock).
  • Framework/strong-name/GAC issues: ensure framework compatibility and that strongly named assemblies are resolved correctly.

Quick runtime check (C#) to confirm an assembly is managed and see its exported types:

using System;
using System.Reflection;

class InspectAssembly
{
    static void Main()
    {
        var asm = Assembly.LoadFrom(@"C:\path\to\library.dll");
        Console.WriteLine(asm.FullName);
        foreach (var t in asm.GetExportedTypes())
            Console.WriteLine(t.FullName);
    }
}

Additional tips

  • For binding failures, use the Assembly Binding Log Viewer (Fuslogvw) to see why the loader failed.
  • For COM DLLs, register with regsvr32 or use tlbimp to generate an interop assembly.
  • Clean/rebuild, verify the DLL is copied to the output folder (Copy Local), and examine inner exceptions for precise error text.

Recommended Answers

All 2 Replies

Are you sure it's a .NET assembly?
Not all dll's work.

it worked I wasn't typing the correct name.

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.