(First things first, I'm kind of new on this type of programming)
I'm trying to make a windows form application where i request data from a PLC so it can be stored in a access database. This application is going to be running on a different computer.
On the solution i created and besides my project I'm using an existing project that works "like" the communication between the app and the PLC, it is called LibplctagWrapper (on my main project I create a reference to this last one)
(https://www.mesta-automation.com/how-to-communicate-to-an-allen-bradley-plc-with-c-and-libplctag-ethernet-ip-library/),
and it works on my PC, but every time y copy the Bin folder to the new computer, then run the app, it opens, but a warning popup messages appears. Saying: Unable to load DLL "plctag.dll": The specified module could not be found. (Exception from HRESULT: 0x8007007E).
The LibplctagWrapper is in another directory than my Solution and Main Project so I moved it to C: so the direction will be the same on the new computer. But it doesn't work.(copy the LibplctagWrapper in C: of the new pc as well)
Moved the entire solution/main project to C: as well... the same result.
Instead of just the bin folder i copied the entire project folder... im thinking the problem goes with the fact that the LibplctagWrapper is not in the same direction? but I don't know how to place it in the same direction... I search on visual studio but I never saw the option to move it.
Unable to load DLL "plctag.dll": The specified module could not be found. (Exception from HRESULT: 0x8007007E).
This error message is quite generic, missing dependencies can cause it as well as the mentioned module not being present at all. Check the Dependency Walker ( http://www.dependencywalker.com/) to discover required C++ runtimes or something alike. Remember to take x86/x64 into consideration.
#JavierMata - I think you have probably resolved this issue, but for others encountering something similar you can use the recently released official wrappers which can be downloaded via nuget. Github link: https://github.com/libplctag/libplctag.NET
The libplctag.NativeImport package handles loading the appropriate C runtime so you don't have to.
For educational purposes, one of our college subjects requires a project that integrates any instance of Prolog with any other GUI supportive language. I went with C# as I have the most experience with it.
I'm trying to learn by example of my fellow college colleagues from higher years. They gave me their repos to download their code and to see how it all comes together. And this is where the problems started.
No matter what I do, what tutorial I follow, what tips from other sources I apply, the error will not change: FileNotFoundException was unhandled: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in SwiPlCs.dll.
I've tried using SWI 32 bit/64 bit, VS 2015/2017 with 32/64 bit builds, redownloading the DLL as a nuget package. None of them seem to work.
InitializeComponent();
igra.popuniSlagalicu += igra_popuniSlagalicu;
igra.vratiOdgovor += igra_vratiOdgovor;
String[] param = { "-q" };
PlEngine.Initialize(param);
PlQuery.PlCall("use_module(sudoku)");
This is the first time I felt helpless and desperate while trying to debug code. Literally stuck on a single line for 5 days without any progress whatsoever.
The error is not very clear, but is caused by the fact that the program needs to know where to find the DLLs that run SWI-Prolog are located. There are a few ways to do this but the simplest is to add the directory (e.g. C:\Program Files\swipl\bin) containing the SWI-Prolog executable (swipl-win.exe) to the Windows system PATH variable.
After changing the system PATH variable you will need to restart Visual Studio if necessary.
I have a simple application using a product activation system offered by cryptlex (cryptlex.com).
The program works correctly on my computer, but when I try to run the program on another machine it returns this error:
I've already made sure that the dll is inside the executable folder and everything looks OK.
When I remove all part of cryptlex the program works perfectly on any machine (x86-x64)
I used depencywalker to check for errors and found these two in the executable that uses cryptlex:
Windows 7 64bits,
.NET Version: 4.0
You can use Process Monitor to record all file activities of the program. Set a filter for your executable. After reproducing the error, save the log as XML file.
Then run ProcMon Analyzer (note: I'm the author of it). It will analyze the file and give a list of DLLs that were not found.
You could also do that manually, but note that some DLLs may not be found at first, but later be found when looking in the %PATH% environment variable etc. The tool will remove all those entries which have PATH NOT FOUND first but SUCCESS later.
While the DLL is present, have you checked the bitrate?
Most C# projects default to building against Any CPU - if the DLL is specific to a bitrate (ie x86 or x64) then it might be that the program picks the wrong bitrate on end machines (usually x86) but the right one on your machine (x64). This is usually best resolved by building out different x86 and x64 versions; it's messier, but only .NET itself is good at using the Any CPU paradigm.
The exception should have detail about what DLL in particular was not found - maybe look closer?
GPSVC and IESHIMS missing should not be a problem; as indicated by the hour glass, they're deferred dependencies anyway.
I wish to use LogParser.DLL assembly, so I test it over normal console application, it worked, then I put it into a server, send to win 2003 for testing(i have no more free space to install services like database), ...
it always returned FileNotFoundException Error in eventViewer logs...
I tried to use stack trace to see what really happen, and I see the DLL does not import at all, afte some searching at Google I find an answer in this web site, which told to use .Net command prompt, and then use import assembly command, if I'm write it was tblimp "file name" /out "new file"
I made my assembly, it was .net 4 so I went to my older VS, and done same to provide a .net 2.0.x compatible DLL, I use it and it worked, but...
New Error Apeared:
Error Msg: Retrieving the COM class factory for component with CLSID
{8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following
error: 80040154. StackTrace: at
FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String
startDate, String endDate)
ILogRecordset rs = null;
try
{
((DebugLogger) _logProviderDebugMode).Log("T1-2", "Debug-EventReaderClass",
EventLogEntryType.Information);
LogQueryClass qry = new LogQueryClass();
COMEventLogInputContextClass eventLogFormat = new COMEventLogInputContextClassClass();
((DebugLogger) _logProviderDebugMode).Log("T1-3", "Debug-EventReaderClass",
EventLogEntryType.Information);
string query = "select * from security WHERE TimeGenerated >= '" + startDate +
"' and TimeGenerated <'" + endDate +
"' and (eventid=560 or eventid=540)";
rs = qry.Execute(query, eventLogFormat);
((DebugLogger) _logProviderDebugMode).Log("T1-4", "Debug-EventReaderClass",
EventLogEntryType.Information);
for (; !rs.atEnd(); rs.moveNext())
{
//Processes
}
}
catch(Exception ex)
{
((DebugLogger)_logProviderDebugMode).Log(
"T1-5\nError Msg: " + ex.Message + "\nStackTrace: " + ex.StackTrace
, "Debug-EventReaderClass",
EventLogEntryType.Error);
}
finally
{
((DebugLogger)_logProviderDebugMode).Log("T1-6", "Debug-EventReaderClass",
EventLogEntryType.Information);
if (rs != null)
rs.close();
}
I tried to catch the exception and see if any data is imported, but it seem rs return nothing, also without the if(rs!=null) in "finally" block again it's it self an error which mean rs is null
Event Type: Information Event Source: EventLoggerService Event Category: None Event ID: 0 Date: 8/5/2012 Time: 2:47:20 AM User: N/A Computer: HF-SERVER-PC Description: Debug-EventReaderClass: T1-2
Class Variable Information:
---------------------------
_logProvider: FileEventReaderService.Services.Logger.EventLogger
_logProviderDebugMode: FileEventReaderService.Services.Logger.DebugLogger
_licenceState: OK
_dataBase: deadManN
_interval: 5
_timeGap: 1
_previousReadTime: 8/5/2012 2:40:19 AM
_lastReadTime: 8/5/2012 2:46:20 AM
_parserLock: System.Object
_subtleTime: TimerLib.SubtleTime
_parserService: FileEventReaderService.Services.Util.ParserService5
_connectionStringBuilder: FileEventReaderService.Services.Util.ConnectionStringBuilder
_lastTime: 18
_minutes: 18
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
the above log, is last log I did before the error, and then it show the log which is logged in "catch" block, so error can be here:
LogQueryClass qry = new LogQueryClass();
COMEventLogInputContextClass eventLogFormat = new COMEventLogInputContextClassClass();
so I again start searching for my error msg, and found some things which I was not able to handle alone,
for example, I see some one said to you need to register the DLL manually or using dllregisterservice or things about putting application to be compile only for 86X CPU type, but I don't wanna do this... cause I don't write this for single user with known hardware and software...
How do I deal with the DLL registering while setup application or any thing else which may help about the matter? of Interop.MSUtil.dll library?
It's so important for me, and still there's too much of time I need, about months after this to just check for logical bugs, not compile ones
This is an old question but I ran into this error and found the accepted answer somewhat difficult to parse.
Ultimately I had to ensure that LogParser was installed and LogParser.dll was registered on the machine where the code is being run. Else I would receive the error shown in the original question.
From my experience, Interop.MSUtil is not a replacement for LogParser.dll but a facilitator.
It's also worth mentioning that Interop.MSUtil is now available via nuget, but after installation you will have to manually add a reference to the DLL in your solution's packages folder, then right-click the reference and set Embed Interop Types to false.
I was about to write a service application and I completed some of it. I encountered the bugs we talked about in question and also comments. Its been some time that has passed, so I can't tell you every thing that happened, but I'll give you the answer which put me out of this:
First thing first, I needed to work through DLL and my own application not some one else application and not running for example log parser with hidden command and with the query as argument through diagosing process...
so I take the DLL,
the DLL alone worked in win application which I provide for test, in the O/S vs was in it, it may was for certificate reason..
but it didn't worked in my other server OS, ...
also inside the service application it come up with a log which told me I have an I/O: FileNotFoundException so I put try catch block and then print the stack trace, the exception told me that once assembly is missing... so I start to search and find that I should import DLL in kinda way, So Step 1:
see what kinda DLL you need, I mean .net version for example I needed .net 2.x based for more support in older OS, but VS 2010 gived me a .net 4.x based DLL, so I refer to Visual studio 2005 in program file
open visual studio folder from all program menu of Start menu, the go to "visual studio tools" folder, and in the end run "visual studio command prompt"
next put your logparser.dll file in a reachable place like c:\temp\
run this command:
tlbimp "c:\temp\logparser.dll" /out:"c:\temp\Interop.MSUtil.dll"
Notice the Interop.MSUtil.dll is the assembly name that application looking for, but you cant directly rename logparser.dll to it
put this into your project, and switch all references from logparser.dll to Interop.MSUtil.dll (it's becasue name spaces are different)
till here I fixed some error, but it's not like service work successfully, new error appeared while running log parser, and caused that class instances return Nulls,..
the error is here:
Error Msg: Retrieving the COM class factory for component with CLSID
{8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following
error: 80040154. StackTrace: at
FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String
startDate, String endDate)
This Step may Cause nothing, but since I experience changes in error msg I put it here
since I wanted to package my application for many users, it wasn't like I tell all of them to run commands, so I searched even more, some people said about registering the DLL, but you can't put logparser.dll in the global assembly catch folder of setup, also later I find out that the registration we do is different than putting assembly in GAC...
also I find out if we want put a DLL into GAC first we can't put logparser cause it exported, but the Introp.MSUtil.dll
also the setup returned error for putting Interop.MSUtil.dll in the GAC folder
The error was about assembly naming, and after some search I find out that the error is for something different, and it happen where assembly is not signed with a pair key...
you can create pair key through cmd, each OS you install have a random key that it generate, and also you can export and import these keys for special certificate matter, naturally these commands have their network engineering user, but we software also use it here...
So Step 2:
Read this section if you experience 8007007E / 8007007F errors...
they are naturally for the reason of registration of assembly and I don't know but maybe also the shared key which DLL is signed with
also one more thing you can perform before doing these is test regsvr32 "[dll file address]" which register a DLL, and if application doesn't directly use and search for DLL you can put it in any folder before registering
for example in our project we point to Introp.MSUtil.dll not logparser.dll though we also need it for registration, and then we run regsvr32 command on logparser.dll (this command is just for testing, and have no use in setup and deploying your application, also you can use /u switch to unregister the DLL for further testing)
create a pair key file using CMD with following command:
sn -k [file name] it create the file in the address you are inside
next again go to step one, but instead of the old command use this new command which also mix key pair to generate the DLL tlbimp "[logparser.dll address]" /out:"[address]\Interop.MSUtil.dll" /pr imary /keyfile:"[pair key file address]"
now use new signed dll instead of the one we create before ... ( Interop.MSUtil.dll )
there was also error exist... so i find out that GAC (Global Assembly Catch) wont work alone, and after fixed all bug, i noticed that i can, but i don't need to put Interop.MSUtil.dll in GAC folder of my setup...
but this registering matter, the regsvr32, was it the problem?
ah yes, it was, though I hear this is same to putting assembly into GAC, but it wasn't right, the registration of DLL as Global Assembly was different than using regsvr32 to register it...
if you want to know your DLL is already registered, i think you need to now the namespace or the main assembly inside of it, so you can go through following step to see if it is registered:
go to start menu and open up "run" tools
type dcomcnfg and press "enter" to open Component Service tools
lead to this directory: Console Root->Component Services->Computers->My Computer->DCOM Config
now for example for seeing if log parser.dll is registered, look for names like "Interop.Msutil" or "MSUtil"
if it is exist, the dll is registered, else it's not
ok, let back to the subject, we need to register the DLL, and it cause some errors which I don't remember... cause classes dont work well and return nulls
if you register logparser.dll using the command and it worked, for packaging your setup you need to do following things So Step 3:
put logparser.dll assembly (which setup know it as file not assembly)
in the reachable folder, like Application Folder of your setup project...
right click over the file inside Solution Explorer and select Properties
click over register section, and over drop down button to see all the available option...
select _vsdrfCOMSelfReg_ from the list, notice that some option like this one is not provided for some assembly like the one we create (Introp.MSUtil.dll) so we cant register it, you also cant register that DLL with regsvr32... other option wont register the DLL as I test
PS: notice that the logparser.dll and the Interop.MSUtil.dll wont detect by project automatically, and you have to add them manually to your Setup and MSI project... you also need both DLL as I explained
With many thanks to #Andrii Kalytiiuk
I'm trying to get started with this library: 32feet
I have a Broadcomm Bluetooth Stack and haven't been able to figure out how to get this library set up. When I run my code, I get:
Unhandled Exception: System.PlatformNotSupportedException: No supported Bluetooth protocol stack found.
After digging around on their site, I found this: Installation instructions
It says to copy the appropriate DLL's into the project and then run the Test32FeetWidcommWin32.exe. I've tried putting the files in every single folder in my Visual Studio project and then running that EXE, but I still get the same error. Initially I tried just adding the InTheHand.Net.Personal.dll file as a reference to my project, but that didn't work either.
What could I be doing wrong?
It may also simply be that BlueTooth is not turned on in Windows.
I was using the .NET InTheHand library, and received this message only because BlueTooth was turned off in Windows, and resolved it by activating BlueTooth.
I just solved this. I think the problem was an old reference in my project to the NETCF version of the DLL from when I was trying to brute-force a solution, so I wiped my project clean and then started adding everything again and it worked!
A helpful tool to those trying to figure out their problem with this is to copy and paste the app.config file into your release directory with the app you are creating, and change the name to <YOUREXENAME>.exe.config. When you then run your EXE file, it should create a more detailed trace file. For mine, I found that coredll.dll was the culprit by not loading and was masked by the Stack not supported exception. After an easy Google search I found the problem to be with NETCF.
edit: To be clear, after I cleaned out my project a bit I re-added the reference to the correct InTheHand.Net.Personal.dll file and also added the 32feetWidcomm.dll file to my Release folder.