.NET Framework - Problems with DLL C#
Asked By Treephwood1978
26-Jan-10 05:38 AM
Hi! (my english not is perfect :) )
I have this problems...
In second dll import i have the error message (EntryPointNotFoundedException).
..
Helpe ME!
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Proof
{
class Program
{
internal const string DllName = "rec1.dll";
[DllImport(DllName, EntryPoint = "Init", SetLastError = true)]
internal static extern long Init(string Name, string Key);
[DllImport(DllName, EntryPoint = "LoadImage", SetLastError = true)]
internal static extern long LoadImage(long SesHandle, string File,
long NumPagina);
public static void Main()
{
long Sessione = Init("version", "version");
long DIBHandle;
Console.WriteLine("Sessione: " + Sessione);
DIBHandle = LoadImage(Sessione, "proof.tif", 0);
Console.WriteLine("Valore DIBHandle: " + DIBHandle);
}
}
}
System.Runtime.InteropServices
(1)
Visual Studio
(1)
System.Collections.Generic
(1)
Console.WriteLine
(1)
DllImport
(1)
DIBHandle
(1)
Console
(1)
SetLastError
(1)
Fábio_Chicout replied to Treephwood1978
Hi Treephwood,
The EntryPointNotFoundedException is thrown when the name of the method in
C# is not the same into your native DLL.
Go to the command prompt (the Visual Studio Command Prompt), use the utility
dumpbin /exports <path_to_your_native_dll>
this is gonna show you all the functions exposed by your dll. Then you have
two choices:
1- Change the signature of your C# method to reflect what is exposed
2- Use the parameter EntryPoint on the DllImport Atribute
Maybe the problem can be solved just compiling your native dll adding to the
signature the modifier:
extern "C"
If you have any doubt yet, send some information (code) 'bout your native
dll.
Att,
F??bio Chicout

T> instead. It has all your required operation. Demo with same type: using System; using System.Collections.Generic; using System.Linq; namespace E { public class Program { public static void Main(string[] args) { List string> { "C", "D", "E", "F" }; foreach(string s in x.Except(y)) { Console.Write(" " + s); } Console.WriteLine(); foreach(string s in y.Except(x)) { Console.Write(" " + s); } Console.WriteLine(); foreach(string s in x.Intersect(y)) { Console.Write(" " + s); } Console.WriteLine(); foreach(string s in x.Union(y)) { Console.Write(" " + s); } Console.WriteLine(); Console.ReadKey
also another component called Utilities where for example Serialization classes is located. using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.IO; using System.Drawing; using System.Windows is Windows or Web UI - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - interface - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - using System.Web.UI.WebControls; using BLL.DTO; using System.Collections.Generic; namespace MVPDemoWeb.Views { public interface IArticleView :IView { int Idx { get; set; } List<DTOArticle> DtoArticles { get TextBox TbxBody { get; set; } } } - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - codebehind for form Article view that implements IArticleView - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- using System; using System.Collections.Generic; using System.Web.UI; using System.Web.UI.WebControls; using MVPDemoWeb.Presenters; using MVPDemoWeb
DLL in VBA erstellen? Gru?? Andy C# - German Discussions Microsoft.Win32.Registry.ClassesRoot.OpenSubKey (1) System.Runtime.InteropServices.ClassInterface (1) System.Runtime.InteropServices.ProgId (1) Microsoft.Win32.Registry.CurrentUser (1) System.Windows.Forms.UserControl (1) Microsoft.Win32.RegistryKey de.german.entwickler.dotnet.csharp&tid = fdad8fa8-303e-44aa-8168-049b72ef6b01 - - Tschau, Stefan Microsoft MVP - Visual Developer ASP / ASP.NET http: / / www.asp-solutions.de / - Consulting, Development http: / / www.aspnetzone.de denn? Du musst einfach die Registrierung von "Hand" machen via ComRegisterFunction / ComUnregisterFunction. . . Zum Beispiel so: [System.Runtime.InteropServices.ProgId("App.ID")] [System.Runtime.InteropServices.Guid("xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")] [System
able to use this LPSTREAM inside of a class that I created to wrap the System.Runtime.InteropServices.ComTypes.IStream interface. This code is based on a sample I found while researching this new Object(); uint uResult = GetAnyStream( out obj ); MyMemoryStream Content = (MyMemoryStream)Marshal.CreateWrapperOfType(obj, typeof(MyMemoryStream)) ; [DllImport("MyDLL.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true, EntryPoint = "vsGetAnyStream", CharSet = CharSet.Auto)] public static extern Interface)] out Object stream ); MemoryStream class [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class MyMemoryStream : MemoryStream, System.Runtime.InteropServices.ComTypes.IStream { public MyMemoryStream() { } public MyMemoryStream(IntPtr ptr2Stream) { } public MyMemoryStream(int Capacity) { } public void ReadBuffer buffer[iOffset] = Marshal.ReadByte((IntPtr)iStreamPtr, (Int32)iOffset); Read(buffer, 0, iByteCount); } catch (Exception ex) { Console.WriteLine("ReadBuffer failed for the following reason: " + ex.Message); } } / / / <summary> / / / Write / / / / / / < / summary> / / / / / / public void Write
Integer Dim bufferDST(bmDST.Width * bmDST.Height - 1) As Integer 'Quellgrafik in Quell-Buffer kopieren System.Runtime.InteropServices.Marshal.Copy(bmdSRC.Scan0, bufferSRC, 0, bufferSRC.Length) 'Ziel-Buffer f?llen For y = 0 bmdDST.Stride + x) = bufferSRC(y * bmdSRC.Stride + x) Next Next 'Ziel-Buffer in Zielgrafik kopieren System.Runtime.InteropServices.Marshal.Copy(bufferDST, 0, bmdDST.Scan0, bufferDST.Length) 'Grafiken freigeben bmSRC.UnlockBits(bmdSRC) bmDST.UnlockBits Imaging.ImageLockMode.ReadOnly, BM.PixelFormat) Dim buffer(BMD.Stride * BMD.Height * 4 - 1) As Byte System.Runtime.InteropServices.Marshal.Copy(BMD.Scan0, buffer, 0, buffer.Length) For y = 0 To BMD.Height