Solved

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

Posted on 2010-09-01
14
2,965 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
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 
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

Independent Software Vendors: 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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

696 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