j# from .net 4.0 application for zip files [duplicate] - zip

I tried to convert a project that relies on the vjs runtime to vs2010, but it errors out when trying to run.
It's giving the error that "Could not load file or assembly 'vjslib' or one of its dependencies. An attempt was made to load a program with an incorrect format."
I reinstalled the vjs runtime, but it didn't seem to help.
Is there any way to get get .net 4 to work with this?

Very simple solution - Calling J# code from .NET 4.0
You take control and load it first supplying an explicit path. Then next time it's needed, it already knows the path (or it's already loaded in the AppDomain).
You will need to use LoadLibrary function, so import the pinvoke reference:
[DllImport("kernel32", SetLastError = true)]
static extern IntPtr LoadLibrary(string lpFileName);
The on load (either Main function in Console/WinForms or in Global.asax Application_Start):
if (Environment.Version.Major >= 4)
{
string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), #"..\Microsoft.NET\Framework\v2.0.50727");
folder = Path.GetFullPath(folder);
LoadLibrary(Path.Combine(folder, "vjsnativ.dll"));
}

I have downloaded Microsoft Visual J# Version 2.0 Redistributable Package from http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=4712 and installed it.The issue is resolved.

I got this to work by copying C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjsnativ.dll (for 64 bit Microsoft.NET\Framework64\v2.0.50727\vjsnativ.dll) to my application's debug/release directory.
I suspect Microsoft will need to release another j# redistributable package to work with .net 4.0. Meanwhile, this work-around does a fine job.

The only way I could get it to work was to copy the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vjsnativ.dll to the C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder. See http://community.microfocus.com/borland/managetrack/starteam/w/knowledge_base/17108.error-unable-to-load-dll-vjsnativ-the-specified-module-could-not-be-found-exception-from-hresult-0x8007007e.aspx

To add to the existing answers, I found that the solutions didn't work for me.
First thing I did was to repair the Microsoft Visual J# 2.0 Redistributable Package -SE (x64) using Windows Control Panel (Just right click and click repair). This was in case I did any damage in my previous attempts to fix the problem.
I had already implemented the solution provided by David Thielen.
1 Extra step closed the deal for me (solved the problem):
Copy "vjscor.dll", "vjslib.dll" and "vjsnativ.dll" from C:\Windows\Microsoft.NET\Framework64\v2.0.50727 To C:\Windows\Microsoft.NET\Framework\v2.0.50727
So basically the Microsoft package placed the correct dlls into the 64-bit .NET framework and I had to manually move them into the 32-bit folder which is then copy-pasted into my solution folder by David Thielen's solution (above).

Related

How do I make a MS VS C++ project standalone?

So I wrote a small script to do some math calculations, but I cant get it to run on another computer. When I try to run it, it says I'm missing multiple dlls. MSVCP140D.dll, VCRUNTIME.dll, and ucrtbased.dll are the ones it says it cant find. The only include I have in the entire doc is iostream, is it somehow linked to specific Visual Studios dlls? and if so how would I go about making it able to run on a different computer.
I am using VS 2019 and windows 10 if that helps in any way.
any and all help appreciated.
You can use static linking of the C Runtime (/MTd or /MT), but it's not recommended in general which is why all VC++ projects default to the DLL version of the CRT (/MDd or /MD).
See Microsoft Docs.

Prevent Visual studio 2017 from copying almost 100 unnecessary system dlls to output folder for dll project

I made a new .NET Class Library solution if TFS, and added a bunch of preexisting classes that were developed for a windows forms application. Basically just dumped the old folder in. The forms app worked fine and the folders in bin were expectedly barren, apart from the exe and the required nuget references. The dll build however copies over libraries all the way from Microsoft.Win32.Primitives.dll, to System.Xml.XPath.XDocument.dll for no apparent reason. I have removed unused references with ReSharper and commented out unnecessary using statements. No difference whatsoever. I don't think it's a problem from the deployment perspective, it's just annoying to have so many files copied over each build. Could it be that the initial presence of Forms just poisoned the new project forever? Any help whatsoever would be much appreciated.
Prevent Visual studio 2017 from copying almost 100 unnecessary system
dlls to output folder for dll project
Please check if your VS2017 is very old and also check if the framework version of your project targets to 4.6 or 4.7.1.
If so, there is an known issue about this issue.
This is a .net standard 2.0/net 4.6/4.7.1 issue which was improved in 4.7.2. You can check this similar issue.
Suggestion
1) you should first update your VS2017 in case some updates fix it.
2) change the framework version of your project to net framework 4.7.2.(if you do not have net frameowork 4.7.2, you should install it in the VS Installer)

How to package VC++ Redistributables (for VS 2013) into a cab file?

How to package VC++ Redistributable runtime library (for Visual Studio 2013 available here) into a cab file that should get downloaded automatically only if needed on the client machine?
The sample packaging given at msdn doesn't help as they have not made mfc120.cab available at the similar url, the way they did for mfc42 as in their sample.
As a workaround (which works) I have created a cab (vcredist_x86.cab) out of the vcredist_x86.exe and invoking it only if any of the dependent runtime libraries are not available. But I believe there could be a direct way of doing things instead of going this odd way.
Here is the inf (inspired by the msdn sample):
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
myModule.ocx=myModule.ocx
mfc120u.dll=mfc120u.dll
msvcr120.dll=msvcr120.dll
msvcp120.dll=msvcp120.dll
[myModule.ocx]
file-win32-x86=thiscab
clsid={C4B5FFD0-6DE6-D47E-A9B1-5CF1D3EE869C}
FileVersion=1.5.0.12
RegisterServer=yes
[mfc120u.dll]
FileVersion=12,00,21005,1
hook=mfc120installer
[msvcr120.dll]
FileVersion=12,00,21005,1
hook=mfc120installer
[msvcp120.dll]
FileVersion=12,00,21005,1
hook=mfc120installer
[mfc120installer]
file-win32-x86=vcredist_x86.cab
run=%EXTRACT_DIR%\vcredist_x86.exe \Q
It would be great to know the right way of packaging this particular version of VS 2013 - similar to the sample given. I don't want to copy the vcredist_x86.exe or the dlls at the server, so that it works fine as given in the msdn sample.

Project is targeting frameworks not installed or are included as part of future updates to Visual Studio

I am attempting to convert the Microsoft.Health C# class library that is installed as part of the HealthVault SDK, using instructions provided here. After following these instructions, I get the following error when attempting to load the project into Visual Studio 2013.
"The project is targeting frameworks hat are either not installed or
are included as part of future updates to Visual Studio. See
http://go.microsoft.com/fwlink/?LinkId=287985"
Visiting the link takes me to .NET SDKs and Downloads. Once there, I have no clue on what needs to be done.
I do realize that one will have to leverage the Portable Class Library Contrib project to fill in some missing bits, especially code related to System.Security. This, I will deal with later.
Any one run into a similar problem?
Maybe so late but for those who have the same problem.
I had the same error in a project which was working perfect before updating VS2013 and finally after 3 hours looking for the source of the error I found that the error is about TargetFrameworkProfile.
In my case I sloved it like so:
Right click in the unloaded project in your solution and click Edit.
Find the TargetFrameworkProfile tag and set it as below:
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
At a guess, this is because you need to specify the TargetFrameworkVersion and TargetFrameworkProfile properties in the project file. Compare the .csproj you are trying to create to a newly created PCL project file, and make sure that everything that's not specific to your project matches.
I ran into the same issue and got it resolved by installing the latest Visual Studio Update

Windows Work flow assemblies not picking up

We we trying to create a work flow dll using Windows Work Flow but we are running into major problems regarding referencing.
1.) We have a class that calls an activity but the class cannot pick up the activity that has already been created
WorkflowAcivity workflowActivity = new WorkflowActivity(string id)
This then throws an error message saying cannot find WorkflowActivity
2.) We then added extra assemblies, like one of our other dll's, Visual Studio also cant find these references when we call a class in those dll's we are referencing.
3.) Intellisence has also stopped working??
What do we do to fix this, is it the version we are using or are there any other assemblies we are missing here??
We have tried opeing the solution on another pc, uninstalled vs 2012 and installed vs 2013 and still have no luck!
Got caused by System.Net.Http.Primitives.dll referencing some dll's that were missing and caused the workflow to break without any warnings.
Removing this dll or adding the referenced dlls back in (System.Runtime.dll and System.Runtime.InteropServices.dll) fixed the problem.
Microsoft ticket for this.

Resources