How register dll (internal) in Visual Studio 2008/2010 in Visual Basic page (.aspx/.vb)

How i can register a dll located in bin section of a Visual Studio Solution without register the dll in a PC?
When i register a gsdll32.dll in a PC, their usage in one page (developet in Visual Basic) is correctly if i import the dll into a page but...
If i heve the some dll in a bin section but not register the dll in a PC thats dont run.

{"Unable to load DLL 'gsdll32.dll': No se puede encontrar el módulo especificado. (Exception from HRESULT: 0x8007007E)"}

Some solution? Thanks
77258840Asked:
Who is Participating?
 
77258840Connect With a Mentor Author Commented:
Not. The diference is
Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal DllInternalPath As String) As Long

and
Dim DllInternalPath as String = "where you are the gsdll32.dll, in Bin"
Dim Largo As Long = LoadLibrary("DllInternalPath") you dont need register vin a PC or Server the Ghostscript.
Thank you
0
 
StephanLead Software EngineerCommented:
Did you add it as reference?
0
 
77258840Author Commented:
When I try to add the reference from Bin I get the following message:
A reference to: "C:\Users\Usuario\Documents\Visual Studio 2010\WebSites\MafWeb\Bin\gsdll32.dll" could not be added. No type libraries were found in the component.
In Bin i have too gsdll32.lib.
In another PC did all the tests imaginable and until ghostscript registered on the PC I could not add the reference.
I need the dll into the solution because, when i sent the application to Serevr, I can not install ghoscript in the Server because I may not.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
alexey_gusevCommented:
use p/invoke
0
 
Mohamed OsamaSenior IT ConsultantCommented:
Do you intend to create a setup package to install your application on the server or is the installation manual / script based ?
I am not sure why installing Ghostscript on the server is an issue, a Program prerequisite installation like GS should not be an issue for the system admin / security admin 
if no Setup project is planned ,you can also add a one liner script to xcopy the DLL in your Application path.


0
 
77258840Author Commented:

I WANT TO USE THIS SAMPLE FROM http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx?msg=3125329 
but my application is buid in Visual Studio 2010 in Visual Basic codebehind.

which is the way to do this in VB? (especially[DllImport("gsdll32.dll... ).  

/// <summary>Create a new instance of Ghostscript.</summary>
/// <param name="pinstance"></param>
/// <param name="caller_handle"></param>
/// <returns>The instance passed to other GS function</returns>
[DllImport("gsdll32.dll", EntryPoint="gsapi_new_instance")]
private static extern int gsapi_new_instance (out IntPtr pinstance,
    IntPtr caller_handle);

/// <summary>This will make the conversion</summary>
/// <param name="instance"></param><param name="argc"></param><param name="argv"></param>
/// <returns>0 if is ok</returns>
[DllImport("gsdll32.dll", EntryPoint="gsapi_init_with_args")]
private static extern int gsapi_init_with_args (IntPtr instance, int argc, IntPtr argv);
/// <summary>Exit the interpreter</summary>
/// <param name="instance"></param><returns></returns>
[DllImport("gsdll32.dll", EntryPoint="gsapi_exit")]
private static extern int gsapi_exit (IntPtr instance);

/// <summary>Destroy an instance of Ghostscript.</summary>
/// <param name="instance"></param>
[DllImport("gsdll32.dll", EntryPoint="gsapi_delete_instance")]
private static extern void gsapi_delete_instance (IntPtr instance);
0
 
alexey_gusevCommented:
use

http://www.developerfusion.com/tools/convert/csharp-to-vb/

to convert your snippet to vb.net online
0
 
alexey_gusevCommented:
ah, and add

Import System.Runtime.InteropServices

0
 
77258840Author Commented:
Thank you to all but I have found the solution on my own.
For have all resources from a gsdll32.dll is necesary to put

Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal DllInternalPath As String) As Long
Public Declare Function gsapi_new_instance Lib "gsdll32.dll" (ByRef lngGSInstance As IntPtr, ByVal lngCallerHandle As IntPtr) As Integer
and other needed declarations...
in the Class declarations.

and after, before the use of dll, in anywhere in the code
        Dim DllInternalPath as String = "xxxxxxxxxxxxxxxxxxxx", Largo As Long = LoadLibrary("DllInternalPath")

with this when you use the needed declarations of gsdll32.dll like (for example)
   
        intReturn = gsapi_new_instance(intGSInstanceHandle, callerHandle)

 
0
 
77258840Author Commented:
thats run
0
 
alexey_gusevCommented:
well, that's exactly the same as in the sample you posted, just old VB syntax :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.