Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-01
14
Medium Priority
?
3,020 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Expert Comment

by:Mohamed Osama
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 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