Solved

VB.net running exe without dll files in folder

Posted on 2006-06-08
10
543 Views
Last Modified: 2008-02-01
I'm converting a vb6 app to vb.net 2003 and have it working the only problem is that if I try running the .exe file without all the "Interop.whatever.dll" files in the same folder, I get an error "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in myprogram.exe . The vb6 program runs fine without any other supporting files needed. I've tried using regasm on the files but it doesn't seem to change anything. How can I get this to run without needing the dll files in the same folder as the exe?
0
Comment
Question by:alterami
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 16865152
Well... If you just ran a converter, it probably made an interop dll to help you call things that the vb6 app used which aren't in vb.net or are done differently. If you find the offending location, you can look for a DotNet equivalent and replace it.  

If the code has to do with files/folders, look for objects in system.io namespace
Without knowing what code you have in the interop file or anything about where it is blowing up it would be hard to solve from here.  

The exception you are getting is pretty obvious.. The program can't find a file and your are not catching that error.
Is this the dll that it can't find or some other file that you are trying to open.

If you want to catch the error, surround the code block where it occurs with

Try

'your code here

Catch ex as system.io.filenotfoundexception
      'handle it or show a message about it
      msgbox(ex.message)
end try


Hope this helps some. Please provide more info for more help.

Shane
0
 

Author Comment

by:alterami
ID: 16865307
I know which files it can't find, the problem is I don't want to have the 8 dll files in the same folder as the exe. I want to be able to put the exe in any folder and have it work the same, without requiring any dll files in the same folder. I want to be able to put the dll files in the system or common files folder and the exe would know where to look for them.
0
 
LVL 8

Expert Comment

by:doraiswamy
ID: 16866009
Check if the .NET framework is up and running properly. If you VB.Net was installed properly you should not get this error.
0
 
LVL 1

Expert Comment

by:MySt1k
ID: 16867173
the interop is created because your application is calling some com component. The interop file must be in the same folder as your app, this is a .net limitation, i cont seem to remember where i found this on msdn.

as i found in another post, you can use IlMerge to merge all your interop files and distribute only one file with your app.

or you can remove any reference to unmanage components in the application aswell...

hope that help.

here is the post i referenced above : http://www.experts-exchange.com/Programming/Q_21424609.html
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 25

Expert Comment

by:SStory
ID: 16869755
Well, as mentioned you  have dependencies to com and if you don't want these DLL's you must rewrite that part of the application to use  .NET components instead of com objects.  This would solve your hole problem--but it is more work.

There is no "convert from vb6 to .NET" without any work.  That would be rare.  At least not to get the type of solution many people want.

Not knowing what your app does sort of limits my suggestions, but I can't imagine why it need be in whatever directory.
Why not just hide the dlls on install, then make shortcuts to anywhere you want, would this not do the same thing?
0
 

Author Comment

by:alterami
ID: 16906862
I don't mind if its dependant on dll files, I just don't want to have to have them in the same folder as the .exe file for it to function. I want to be able to move the .exe file around and put it into several different locations and be able to run it. Is there a way I can register the interop files and just put them into a common files folder somewhere, so that anytime I run the .exe file no matter which folder its in on my pc, that it would know where to look for them, and doesn't need them in the same folder?
0
 
LVL 1

Accepted Solution

by:
MySt1k earned 250 total points
ID: 16908641
as i said earlier, i don't think it is possible.

you can try to add the interop into the gac, but it is a bit complicated and i dont guarantee it'll work because i couldn't get it to work.
here is what i tried,
generate a new key pair with : sn.exe -k keyfile.snk

create a new interop file from the type lib you are using. it must be signed to add to the gac.
tlbimp.exe yourTlbPath /out:CurrentInteropPathAndName /keyfile:keyfile.snk

Install the file to the gac.
gacutil.exe /i CurrentInteropPathAndName


hope this works for you ... waiting for your feedback.
0
 
LVL 25

Assisted Solution

by:SStory
SStory earned 250 total points
ID: 16912931
GAC is the only thing I can think of also.  Not sure if that would work either.
You know you can, as I said, hide them on install.

Sorry I can't think of any other way.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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

20 Experts available now in Live!

Get 1:1 Help Now