Embedding EMGUCV as resource - vb.net

I'm working on an application that requires EmguCV. I've gotten EmguCV dlls to load, but I'm stuck on another folder for EmguCV. The x86 folder contains a bunch of vital dlls (such as ffmpeg) and is required. But whenever I load my application, it says it cannot find cvextern (because it's searching in a x86 folder, that isn't there.) I added a folder to my resources with the same name and dlls in it, but it still cannot find it.
I've searched for a long time, with no results.
Is there anyway to embed EmguCV as a resource?

Related

Are VB.net References embedded in the compiled code?

I am writing a commercial application in VB.Net using VS2010. My application needs to access a MySQL database. So I have a reference to MySQL.Data.dll in the "References" section of my Project. For licensing reasons, I want to make sure that this dll file is not embedded in my application. From what I read, if I set the "copy local" property to False, then the file is not copied and I need to specifically copy it to my bin directory. So I set it to False and built my project. When I run it, I can still connect to the MySQL database even though the dll is not in the bin directory. To me this indicates that it is being compiled with the build. However, the reference points to a location on my hard drive where the original MySQL.data.dll resides. Could it still find it there when the program is run?
How can I make sure it is not getting compiled? Thanks.
By the way, it is not in the GAC (I checked using gacutil.exe)
If you're referring to having the actual assembly embedded into yours, then no it does not. It can be done, but it does not happen out of the box.
The application looks at many places for your references when it needs to load it.
GAC
Next to the application (maybe also the consuming assembly)
x64 and x86 folders next to the application (maybe also the consuming assembly)
Any paths specified in the app.config/web.config for the referenced assembly.
Keep in mind that just because your application fired up, it doesn't mean it found all of the references. It more than likely hasn't loaded all of them yet as it will only do it once it is needed.

How to force creation of manifest file in release folder?

This is driving me crazy. I have developed a .NET COM DLL that is used by a VB6 DLL wrapper in order to update and replace some legacy functions in an application.
I am now trying to remove the requirement to use regasm on client machines so have worked out how to do that on a test DLL which all works fine.
I branched the DLL just in case and added an app.manifest file. Everything else worked out fine and I got it all working. The manifest is embedded and Visual Studio 2012 generates a mydll.dll.manifest file in the release folder.
Then I went back to the original trunk and added an app.manifest file (no point in merging as there were no code changes). I copied the contents of the branch into the app.manifest file and built the release version. The manifest is embedded in the DLL but no mydll.dll.manifest file is generated.
I know that it's not strictly necessary to have the mydll.dll.manifest file but I'd like things to be consistent (and for some reason the test process doesn't produce the same results with the trunk version) so how can I force it to be created?
This is a VB.NET DLL project so it doesn't have (or I can't find) the 'Generate Manifest' property drop down mentioned in the first answer here. How can I set this? Or is there a way to set it by editing the project file directly?
References:
Original walkthrough article and some corrections.
Overview by Junfeng Zhang in two articles plus a useful tool
You are making a fairly common mistake. A reg-free COM manifest helps an application find a COM server without looking in the registry to locate the DLL. Embedding the manifest in the DLL is like trying to solve the chicken and egg problem, Windows cannot possibly find that manifest if it cannot locate the DLL first.
The manifest needs to be part of the client app. Which is tricky since it is VB6, it doesn't support embedding manifests in its executables.
You could tinker with the mt.exe tool, an SDK utility that supports embedding manifests in an executable. You'd have to run it by hand after building the VB6 binaries. That's unfun and very likely to cause trouble when you forget. It is in general not a joyful tool to use, documentation is meager, incomplete and unhelpful, a chronic problem with manifests.
The fall back is a separate app.exe.manifest file, what Windows will look for next when it cannot find a manifest embedded in the executable. Where "app.exe" must be renamed to the name of the VB6 program. The EXE, not the DLL. This now also gives you a chance to avoid having to register the VB6 DLL, presumably what you really want if you truly want to make your program run reg-free. The disadvantage is that it will not work when you debug your VB6 program, wrong EXE. You'd also need a vb6.exe.manifest, located in the VB6 install directory.
Needless to say perhaps, very hard to get ahead with VB6 here. It just wasn't made to help you do this, they didn't have a time machine in 1998.
I have to admit that I don't know VB at all, but in the case of C++ and C# Visual Studio projects I previously had to resort to calling mt.exe in a post-build step in order to get the DLL manifest I wanted. Maybe that workaround would work in your case as well?

Replacing dll with same dll fixes the issue, but why?

I have done extensive testing with this and have isolated the problem to this. I'm trying to keep this to the point but please ask if there's any other information you feel I'm leaving out.
-a.exe is our vb6 app that references x.dll
-x.dll is an in house vb6 dll that references y.dll
-y.dll is an in house .net interop dll
-Everything works fine on the development machines.
-I have more than triple checked our .net setup project to ensure files are being pulled from the correct places.
When installed, a call from x.dll to y.dll fails. Ultimately how I am able to fix this is by copying x.dll from the development machine over the x.dll file that was installed by the setup project on the target machine. These two should be identical.
Anyone have any clues whatsoever what this could be? It's pretty much the strangest dll problem I think I've ever had :(
Though I fixed the problem, I still don't completely understand why there was a problem but here's what I found...
Vb6 always wants to change the dll being referenced to the one most recently registered. We used to register dlls to an application directory located in C:\ and not within the source code folders, and we referenced them from there, and grabbed them from that directory for the install package.
When we switched to subversion we moved the dlls into a dependency folder within the branch. However, the dlls continued getting copied and registered to the application directory as well where the build would grab them from. I had to update the build to grab the dlls from the new branch location and stop them from being copied to the old location.
That seems to have fixed the problem, but I don't fully know why because a comparison of the dlls in both locations showed they were identical.

VB.NET: Build project, then share application: OK?

In VB.NET, my application is quite simple, and it accesses many images and creates a list with them.
The images are in my application's Resources folder.
The images are accessed in my code where I typed the path, in my PC, how to reach said folder.
Works like a charm, my project displays the images etc.
Now I go to Debug->Build.
Now I go to the bin folder, release folder, and find my application. I upload it.
I share the download to a friend.
My question is, will the images my application should show will appear? Considering the path I created in the code was manually written?
Are the images compiled into your project as "Embedded Resources" or placed in a .resx file? Is the code that you've written accessing them from your project's Resources folder? If so, then everything will work just fine when you copy the application to another computer and run it.
If you're hard-coding a path to your file system, then no; your application won't work on another computer because those files won't be distributed along with the bare executable. There's really no reason to ever do this.
It's difficult to tell from the information provided in your question what exactly you're doing. For more information about embedding resources into your application itself, so all you have to do is distribute the executable, see this simple how-to guide: Using Resources in Visual Studio .NET

VB.net app without installation

Is it possible to create a VB.Net application which users can just run without installing it first.
If not, is it possible in another .Net language.
If not, how IS it possible :)
PS: The application only has to run under Windows (>= XP).
If they have the .NET Framework installed (the version of it that you developed it), they only need the .exe. You can find the .exe file in the bin directory of your projects folder in your Visual Studio workspace.
If they do not have the framework installed, you'll need to produce an installation for them. It's extremely easy with Visual Studio by just creating a setup project in the same solution as your code.
As long as the user has the .net runtime installed, and your exe has any needed resources in the same folder (dll's, images, ect) theres no problem with that.
If you mean without installing the .net framework though, that won't be possible.
just build the program, and go into the (assuming the project name is app1) app1/app1/bin/debug/ dir. there should be a file there called app1.exe. this file is the compiled .exe from you project. any other computer will be able to run this without doing any installation (provided they have the .NET framework installed (it comes standard on any computer with an os > WinXP))
EDIT: If you were building with debug configuration, it would be app1/app1/bin/debug/, but if you were building with release configuration (which would probably be a better idea if you are distributing) the path would be app1/app1/bin/release/
If you mean running it without the .NET Framework, it used to be possible, but apparently the company's website is no longer in English so I have no idea what's happened to it.
EDIT: If you were building with debug configuration, it would be
app1/app1/bin/debug/, but if you were building with release
configuration (which would probably be a better idea if you are
distributing) the path would be app1/app1/bin/release/
I am developer and have no administration rights to live(production) network.
I had to find away to deploy an app without installation... and my app is self updating this cause other problems too....
The production network Computer check/monitors the file versions etc, so updating in the program files can not be done, where a MSI has been used for deployment.
Using this above I am able to copy and Run the App from the User Profile (where the user has full rights).
lets understand how program runs-
an .exe needs some function which are not inside the .exe, such as , for example substring() function. these predefined function resides in some .dll libraries.
when .exe is executed by user, .exe first finds the .dll and then the function inside that particular .dll.
.exe first looks within the current folder for that .dll
if not found then it searches that in PATHs. (PATH is Environment variable which value is a list of folders such as System32 etc.)
an .exe usually needs only 3 things - .exe itself, .dll which predefined function it is using, and some ActiveX controls(.ocx). apart from these 3, .exe only uses resources (such as icons etc).
lets focus on these 3(.exe, .dll, .ocx)
first you need to check what .dlls your .exe is using. you can easiely do this by using a dependency walker.
then make sure all these .dlls (that dependency walker is showing,or in other words- all these dlls whose functions your .exe needs) are either in current folder(in which your .exe resides) or in the PATHs.
if this step is done then your .exe has high chances to run whithout "installing".
the only problem is that some .dll and all of .ocx, needs to be registered first(means they have to have some kind of registry entry). they are not ready to use just by copying and pasting in current folder or PATHs.
but you can register these .dlls and .ocx's by using regsvr32 (with command line).
after that your .exe should not face any problem to run successfully.
hope you got the main concept.