Hi,

i made a DLL from a Class Library project in C# and i am trying to use it using DllImport but i keep getting:

Error RegConfig.exe MissingMethodException Can't find an entry point 'IntProg' in a PInvoke DLL 'ClassLibraryWinCe.dll' at RegConfig.Program.Main()


when i try to run the program.


MyWinCeClasses:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.Security;
using System.Reflection;


namespace ClassLibraryWinCe
{
    public class MyWinCeClasses
    {
        public static void InitProg(string Location)
        {
            RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"Init", true);

            reg.SetValue("Launch53", Location, RegistryValueKind.String);
            reg.SetValue("Depend53", new byte[] { 0x14, 0x00 }, RegistryValueKind.Binary);
            reg.Flush();
            reg.Close();

            Console.WriteLine("registry set!");
        }
    }
}

RegConfig:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Collections;
using System.Threading;
using System.Security;
using System.Reflection;
using ClassLibraryWinCe;


namespace RegConfig
{
    

    class Program
    {
        [DllImport("ClassLibraryWinCe.dll")]
        public static extern void InitProg(string Location);

        static void Main(string[] args)
        {
            InitProg("\\Storage Card\\OpenIntApp\\OpenIntApp\\bin\\Release\\OpenIntApp.exe");
        }
    }
}

Recommended Answers

All 4 Replies

DLLImport is for DLLs that weren't written in managed code. All you need to do is add the DLL to your project references, include a 'using' statement for the namespace and you can use what is in the DLL.

thanks Momerath for your reply

i have done this and it works, problem is that i would like to have a DLL in a certain library and have many programs reference that DLL. with the method of referencing the DLL (like you said) it seems the executable must be at the same library as the DLL, is there a way to change that?

PS the programs are for Windows Ce

Thx again & BR

Adding a reference does not make the DLL a part of your executable. If you copy the exe to another machine it will not run unless you copy the DLL also (just like any other DLL).

If you want to just have one copy of your DLL per machine (instead of one per executable) you might want to look into the Global Assembly Cache. This is a location where the system looks for DLLs first.

I will try that.
Thx alot, you helped me greatly :)

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.