Hell DLL !!!

D

Dani

Dani,

I am goint to get crazy. I hate dll but... Ok, sorry my english, i am spanish. I am have been making some sample try. I implement a simple class in c#.


using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

then, i compile it, i use csc /t:library simple.cs, it return me a fantastic simple.dll. Ok. Well Done, it works fine. But... Ok I continue. Then I implement a application in c# also. My code...


using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
static extern string getHello();

static void Main()
{
Console.WriteLine(getHello());
}

}
}

then i compile it and a get a nice executable. I run it a get an

Excepción no controlada del tipo 'System.EntryPointNotFoundException' en Class1.exe
Información adicional: No se puede encontrar el punto de entrada en el archivo DLL simple.dll.

I'm going to translate ( I can do it, i think...)

EXCEPTION : System.DllNotFoundException.
CAN FIND ENTRY POINT IN DLL SIMPLE.DLL


I know that import dinamic dll is posibile with Reflexion, buy i am going to use it under Compact Framework, and Reflexion class is not supported in it.

Can someone help me???

Thanks.
 
R

Robby

I think you have to use its complete name.

Yo creo que puedes usar se llama completo.

static extern string Class1.getHello();


Robby

Lo siento, Espanol no es mi idioma premiro.



Dani,

I am goint to get crazy. I hate dll but... Ok, sorry my english, i am
spanish. I am have been making some sample try. I implement a simple class
in c#.


using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

then, i compile it, i use csc /t:library simple.cs, it return me a fantastic
simple.dll. Ok. Well Done, it works fine. But... Ok I continue. Then I
implement a application in c# also. My code...


using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
static extern string getHello();

static void Main()
{
Console.WriteLine(getHello());
}

}
}

then i compile it and a get a nice executable. I run it a get an

Excepción no controlada del tipo 'System.EntryPointNotFoundException' en
Class1.exe
Información adicional: No se puede encontrar el punto de entrada en el
archivo DLL simple.dll.

I'm going to translate ( I can do it, i think...)

EXCEPTION : System.DllNotFoundException.
CAN FIND ENTRY POINT IN DLL SIMPLE.DLL


I know that import dinamic dll is posibile with Reflexion, buy i am going to
use it under Compact Framework, and Reflexion class is not supported in it.

Can someone help me???

Thanks.
 
D

Dani

Ok, I have modify my code. but...

//SIMPLE.CS
using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

//CLASS1.CS
using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
extern string Hello.getHello();

static void Main()
{
Console.WriteLine(Hello.getHello());
}

}
}

But nothing, when i run it. I get next message..

CAN'T FIND NAMESPACE HELLO....(NEED ANY USING...?)

I hate dll, did you know it???

Thanks.
 
R

Robby

I forgot the namespace.

Yo olvido el namespace.

extern string p1.Hello.getHello


Robby

Dani said:
Ok, I have modify my code. but...

//SIMPLE.CS
using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

//CLASS1.CS
using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
extern string Hello.getHello();

static void Main()
{
Console.WriteLine(Hello.getHello());
}

}
}

But nothing, when i run it. I get next message..

CAN'T FIND NAMESPACE HELLO....(NEED ANY USING...?)

I hate dll, did you know it???

Thanks.



Robby said:
I think you have to use its complete name.

Yo creo que puedes usar se llama completo.

static extern string Class1.getHello();


Robby

Lo siento, Espanol no es mi idioma premiro.



Dani,

I am goint to get crazy. I hate dll but... Ok, sorry my english, i am
spanish. I am have been making some sample try. I implement a simple
class in c#.


using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

then, i compile it, i use csc /t:library simple.cs, it return me a
fantastic simple.dll. Ok. Well Done, it works fine. But... Ok I continue.
Then I implement a application in c# also. My code...


using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
static extern string getHello();

static void Main()
{
Console.WriteLine(getHello());
}

}
}

then i compile it and a get a nice executable. I run it a get an

Excepción no controlada del tipo 'System.EntryPointNotFoundException' en
Class1.exe
Información adicional: No se puede encontrar el punto de entrada en el
archivo DLL simple.dll.

I'm going to translate ( I can do it, i think...)

EXCEPTION : System.DllNotFoundException.
CAN FIND ENTRY POINT IN DLL SIMPLE.DLL


I know that import dinamic dll is posibile with Reflexion, buy i am going
to use it under Compact Framework, and Reflexion class is not supported
in it.

Can someone help me???

Thanks.
 
J

John M Deal

Wait a second. Are you using C# as your programming language (I'm
guessing so because you mentioned compiling with csc which is the C#
compiler). If this is the case you don't need the
System.Runtime.InteropServices, DllImport or extern parts of your
program, you would only need them if Simple.cs was a Win32 DLL, it isn't
from what you've shown it is also a C# .Net DLL. What you need to add
is a using statement to p2 that says:

using p1;

Then simply call the static method from your p2.class like:

Hello.getHello();

The point of InteropServices is to allow interoperability with COM
components. DllImport is meant for Win32 DLL usage. Using statements
are meant for .Net components (if you compiled using the proper
references command line switch and have the .Net DLL in a location that
can be found by your executable. Hopefully that clears up the
confusion. If not post back and I'll get a copy of your code working
and send it to you.

Have A Better One!

John M Deal, MCP
Necessity Software
Ok, I have modify my code. but...

//SIMPLE.CS
using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

//CLASS1.CS
using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
extern string Hello.getHello();

static void Main()
{
Console.WriteLine(Hello.getHello());
}

}
}

But nothing, when i run it. I get next message..

CAN'T FIND NAMESPACE HELLO....(NEED ANY USING...?)

I hate dll, did you know it???

Thanks.



I think you have to use its complete name.

Yo creo que puedes usar se llama completo.

static extern string Class1.getHello();


Robby

Lo siento, Espanol no es mi idioma premiro.



Dani,

I am goint to get crazy. I hate dll but... Ok, sorry my english, i am
spanish. I am have been making some sample try. I implement a simple class
in c#.


using System;

namespace p1
{
public class Hello {

public static string getHello(){ return "HELLO"; }
}
}

then, i compile it, i use csc /t:library simple.cs, it return me a
fantastic simple.dll. Ok. Well Done, it works fine. But... Ok I continue.
Then I implement a application in c# also. My code...


using System;
using System.Runtime.InteropServices;

namespace p2
{

class Class1
{

[DllImport("simple.dll")]
static extern string getHello();

static void Main()
{
Console.WriteLine(getHello());
}

}
}

then i compile it and a get a nice executable. I run it a get an

Excepción no controlada del tipo 'System.EntryPointNotFoundException' en
Class1.exe
Información adicional: No se puede encontrar el punto de entrada en el
archivo DLL simple.dll.

I'm going to translate ( I can do it, i think...)

EXCEPTION : System.DllNotFoundException.
CAN FIND ENTRY POINT IN DLL SIMPLE.DLL


I know that import dinamic dll is posibile with Reflexion, buy i am going
to use it under Compact Framework, and Reflexion class is not supported in
it.

Can someone help me???

Thanks.
 
J

jeff_louie

As suggested, just add a reference to the C# dll. To clarify:

Call managed dll in C# --> http://www.geocities.com/jeff_louie/OOP/oop13.htm
Write and call a managed dll in IL Assember --> http://www.geocities.com/jeff_louie/IL_Net/
calling_il_dll.htm
Call Win32 dll from C# --> http://www.geocities.com/jeff_louie/COM_Interop/pinvoke.htm
Write C++ COM dll and call from C# --> http://www.geocities.com/jeff_louie/COM_Interop/
atl_com.htm

Regards,
Jeff
I am goint to get crazy. I hate dll but... Ok, sorry my english, i am =
spanish. I am have been making some sample try. I implement a simple =
class in c#.=20 <


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
W

Wiktor Zychla

you've completely misunderstood the idea of managed dll and unmanaged dll.
you've tried to use managed dll as unmanaged dll. this will not work at all!

instead, use your dll in proper way:

using System;
using p1;

namespace p2
{
class Class1
{

static void Main()
{
Console.WriteLine(Hello.getHello());
}
}

csc.exe /r:simple.dll source.cs

regards,
Wiktor Zychla
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top