Solved

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

Posted on 2010-09-01
14
2,871 Views
Last Modified: 2013-11-27
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
0
Comment
Question by:77258840
14 Comments
 
LVL 16

Expert Comment

by:Stephan
ID: 33577379
Did you add it as reference?
0
 

Author Comment

by:77258840
ID: 33586589
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
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33630220
use p/invoke
0
 
LVL 23

Expert Comment

by:Admin3k
ID: 33644921
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
 

Author Comment

by:77258840
ID: 33646446

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33646496
use

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

to convert your snippet to vb.net online
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33646517
ah, and add

Import System.Runtime.InteropServices

0
 

Author Comment

by:77258840
ID: 33648003
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
 

Author Comment

by:77258840
ID: 33648012
thats run
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33648088
well, that's exactly the same as in the sample you posted, just old VB syntax :)
0
 

Accepted Solution

by:
77258840 earned 0 total points
ID: 33652422
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now