Reputation: 851
I got a Project with several classes which should work like a P/Invoke collection for me.
For example
namespace Win32
{
static class Winspool
{
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
public static extern uint GetPrinterData(
IntPtr hPrinter,
string pValueName,
out uint pType,
byte[] pData,
uint nSize,
out uint pcbNeeded);
}
}
The project is much bigger and got only DllImports, [StructLayout(LayoutKind.Sequential)], Flags, Structs, Enums etc. a lot of things from the win32 api.
The project should be compiled to a dll-file because I need to call several Win32 functions here and there in my projects and dont want the dllimport declerations in my code.
My question now: Is it possible to use this dll in any other C#-Project and call the imported functions?
I've tried to add my dll via reference but I was not able to call anything out of my dll.
Upvotes: 0
Views: 158
Reputation: 151720
Because your class is not public
, it will have the default visibility of internal
and will not be visible from outside its own assembly.
So if you make it public
:
public static class Winspool
{
}
Then you can access it from other assemblies:
Win32.Winspool.GetPrinterData(...);
Upvotes: 2