Okuma THINC API Dependency File Not Found Exception - c#

I have to convert a very very simple program from Vb to C#.
The Vb has those references
From seeing here if I am not mistaken those should be managed dlls. I achieve the same result if I follow the procedure here with the dumpbin.exe program.
So everything should be fine.
But when I do that CWorkpiece instance = new CWorkpiece(); I get the following error
which tells that the relevant dll is not in the right place.
However the file is right were it should be
That said I have thought that perhaps I had done a wrong investigation but adding the following lines didn't help
[DllImport("C:\\Temp\\1\\Okuma.CLDATAPI.dll")]
public static extern int CWorkpiece();
So in short the problem is all related with that dll which can't be found
Thank you in advance for any help
Patrick

Refer to Section "4.5.1.3.3.1 Missing library file" of the THINC API Installation Manual.
All applications developed with .NET THINC-API libraries are required to include an exact version of THINC-API libraries with the custom installation. THINC-API libraries compiled with application should
be installed with your application folder.
The above error message shows that THINC-API library named Okuma.CLDATAPI.dll cannot be found at the folder where the application runs from.
Solution: Include THINC-API libraries compiled in your application with your custom setup and re-install
your application with new setup.
Yes the THINC API libraries are managed .NET libraries. The command (CMD) API is written in VB, and the data API in VC++. Depending on the API version you have, these libraries either written in .NET 1.1 or 4.0.
So you really shouldn't be attempting to Pinvoke them.
The real problem you are facing is attempting to run your program in an environment which does not have the THINC API installed. Yes, you have the libraries referenced by your application, but that is not enough.
The THINC API libraries have several dependencies including:
Okuma.FlexNet.dll
Okuma.ApiLog.dll / Okuma.Api.LogService.dll
LDATAPI.dll / MDATAPI.dll / GDATAPI.dll
LCMDAPI.exe / MCMDAPI.exe / GCMDAPI.exe
PIODlib.dll
Softswitch.exe
Solution
Obtain a copy of the API Install disc; either from a disc that has shipped with an Okuma machine, or a new version through your Okuma dealer.
Install the development version of the THINC API in your development environment.
Note that you will not be able to Init() or call any other API functions unless your environment is one of the following:
An actual Okuma Machine with CAPI Option and THINC API Installed
An "NC-Master" Simulator such as this:
Or a PC NC-Master which is an all software simulator.

Related

How to Install a Driver as Part of a Winforms App

I am currently working on a WinForms app in Visual Studio 2019, which uses a USB to I2C adapter to read EEPROM register values from a device. The manufacturer of the adapter provides the driver for the device in a downloadable zip file on their website which contains the .inf and .sys files among other things. I would like to have it so when the end user installs the app, the driver is automatically installed as well. What is the best way to do this? I have a Setup project in my solution, which I can use to put the driver files in the application folder, but that doesn't mean the driver is actually set up.
I found one potential solution that used System.Configuration.Install, but my targeted framework at the moment is .NET core 3.1, which unlike .NET framework does not have that namespace. I am only expecting users to use Windows 10, so I theoretically could switch to .NET framework for that namespace if necessary. However, I don't know if that will break anything in the app or if that is the easiest way to go about this.
I am very new to deploying apps so I really don't know the best way to go about this. Any direction is appreciated.
There are third-party .net core ways of doing this, such as
Core.System.Configuration.Install
Porting of System.Configuration.Install for .NET Core. (.NET 4.0
version)
Use at your own risk
however, there are also oodles of installers that have this capabilities.
Lastly, this can also be done with powershell, P/invoke and I believe there was talk in github about releasing this source code however you will need to track that down and follow the trail yourself

Sharing a DLL between projects

Microsoft says it's platform neutral these days, so I'm trying to build on Mac and Linux only with VS Code and deploy to Azure. Why? It's mainly to prove that I can.
Our project has several parts which include a couple of different websites, a Web API, er API and a few other bits. On my Mac I've built a .Net Core Class Library with a load of objects in. Command line, dotnet build, DLL out, no problem.
I want to put that DLL on the Linux machine where the MVC website is being built - the objects forming the models part of that site hopefully. I cannot figure out how to get the website project to reference my DLL and use the objects.
I had assumed I copy it to the other machine, place it in the bin folder of the site being developed and reference it in the Dependencies section of the site's project.json. Nope. I saw a few articles that said .Net Core only works with NuGet and it had to be a package. Is that really true?
I've found and read (if not entirely understood) everything you could imagine on sharing between .net core and .net framework. This is a core-only project so not applicable. Frankly I'm lost, and something called .Net Standard has just rolled into my field of vision.
So instead of copying the DLL, use dotnet pack to build a nuget package on your Mac, and copy that to your Linux machine instead. Put it in a directory that you configure as a local nuget repository (no server or anything required) and you're away.
I agree it's not as straightforward as a reference to a DLL, but it's not too bad. Note that you'll need to version the package appropriately, so that the tool system can detect when it's changed.

Why is WinHttpHandler causing "Unable to load DLL 'api-ms-win-core-localization-l1-2-0.dll'" on production server?

We've started using the WinHttpHandler NuGet package in an ASP.NET application. On the development machines it's working fine, and also works on our staging environment. The application targets .NET 4.6.1.
However, on production it throws the following error:
System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-localization-l1-2-0.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I have googled quite a lot about this problem, but couldn't find any meaningful information about this dll. (I found in forums that some people manually copied the dlls to their production servers when having similar issues, but that doesn't seem to be the proper solution.)
Where is this dll coming from? Should it be explicitly installed?
(On my dev machine I found it in C:\Windows\System32, on our staging machine it's in C:\Windows\System32\downlevel, but I don't know where it's coming from.)
I think you have a problem with API Sets.
That dll is only available for Windows 8 API Sets, and as it is stated on msdn
API Sets rely on operating system support in the library loader to
effectively introduce a namespace redirection component into the
library binding process. Subject to various inputs, including the API
Set name and the binding (import) context, the library loader performs
a runtime redirection of the reference to a target host binary that
houses the appropriate implementation of the API Set.
So my suggestion is to contact the owner of the package and describe in detail the environment in which you are using that package (operating system, Target .Net Framework Identifier, Target .Net Framework Version, etc).
Hopefully they will find and fix the error.
UPDATE: Here is a discussion on GitHub page of the package. The proper long-term solution for this problem is not clear yet.
TLDR: Installing Visual C++ Redistributable for Visual Studio 2015 solves the problem.

Adding .NET Framework DLL as reference to windows store app

I'm working on a windows store app project where I want to read a simple temperature measurement data from a National Instruments DAQ. However the DLL library for the DAQ is in .NETFramework 4.0 format and when adding this as reference to my windows store app project I get the following error: "The project targets ‘.NetFramework’ while the file reference targets ‘.NetCore’"
Searching the net, I found out that windows store app must use references to another .NETCore or Portable Library binary only, it cannot reference a full .NET 4.0 library. I guess there is many people who have similar problems,so I wonder if there is any walk around tricks out there?
If you're stuck with using a library supplied by someone else, and if attempts to lobby them to produce a portable version are unlikely to succeed, then about the only thing you can do is find somewhere else to host the DLL, and then communicate with whatever is hosting it. For example, for some scenarios it may be possible to write, say, an ASP.NET Web API based service, which will be able to use the full .NET Framework and will thus be able to use the DLL.
Obviously, this trades one problem for another: you now need to have a machine which can run a web service for you. (And unfortunately, I believe Microsoft does not officially support running that web app on the same machine that's running the Windows Store app. You may be able to get it to work on your dev box, but you'll not be able to deploy the web app itself via the Windows Store.)
And there's no easy path here - you'll have to write a layer exposing everything you need via HTTP services, and client-side code to consume those services. And you'll also need to think about how to to secure access to the service.
It may be easier to plead with your supplier...
In theory, if it so happens that the library isn't using anything outside of the core .NET profile, then you could use ILDASM and ILASM to de-compile and re-compile the code, converting it to a portable library before doing so. However, this is quite likely to breach your license agreement if it's commercial code, and in any case, is quite likely not to work.
The "workaround" is to create a version of the library you want as a portable library. That's all there is to it. You simply don't have the full framework available.
The difficulty involved in converting a class library to a portable class library depends heavily on what the library does, and which areas of the BCL it uses.

How to include third Party dll files in Mono 2.10?

I have developed an windows desktop Application using C# .NET 4 framwork.Now, we are going to using MONO2.10 for cross platform.For sample, I have downloaded the mono 2.10 on windows version and able to run my .net exe.While doing so, Its Working fine and it says error the below mentioned error msg. As per my understanding, I think the DLL Reference is not included properly...
i am using 2 third party dll files in application.
Ionic.dll for .net zip library
DocumentFormat.OpenXml.dll for XML file management.
Please guide me to how to include these dll reference in Mono on windows?
Thanks & Regards,
Saravanan.P
This library is not part of Microsoft .NET or Mono Framework.
Therefore, you just need to either put it in GAC or in the same folder with your application, just like you normally do with third-party components.

Categories