System.io.filenotfoundexception Unable To Find Kernel32.dll In The Specified Process

2 views
Skip to first unread message

Lucia

unread,
Aug 5, 2024, 2:29:12 AM8/5/24
to milosibrou
Thisis the third part in the series named Debugging common .NET exceptions. Today, I want to help you track down and fix a very common and very well-known exception, System.IO.FileNotFoundException. Admitted! In all instances this error is caused by trying to access a file that isn't there. But, there are actually multiple scenarios that can trigger this exception. You may think you know everything there is to know about this exception, but I bet there is something left for you to learn. At least I did while digging down into the details for this post. Stay tuned to get the full story.

line 3 is the important one here. I'm trying to load a file that doesn't exist on the file system (non-existing.file). In the example above, the program will print output to the console looking similar to this:


APP_PATH will be the absolute path to the file that cannot be found. This type of FileNotFoundException actually contains all the information needed to debug the problem. The exception message contains a nice error description, as well as an absolute path to the missing file. If you want to present the user with the path or maybe create the file when not found, there is a nifty property available on FileNotFoundException:


In the example I simply create the missing file by using the Filename property. I've seen code parsing the exception message to get the name of the missing file, which is kind of a downer when the absolute path is available right there on the exception :)


Unlike the error thrown on reading the missing file, messages from the System.Reflection namespace are harder to understand. To find the cause of this error you will need to look through the stack trace, which hints that this is during Assembly.LoadFile. Notice that no filename is present in the exception message and in this case, the Filename property on FileNotFoundException is null.


An error similar to the one above is the Could not load file or assembly 'assembly' or one of its dependencies. The system cannot find the file specified. error. This also means that the program is trying to load an assembly that could not be found. The error can be re-created by creating a program that uses another assembly. Build the program, remove the references assembly (the .dll file) from the bin\Debug folder and run the program. In this case, the program fails during startup:


Until now all instances of this error have been a missing file from the disk. I want to round off this post with a quick comment about security. In some cases, the FileNotFoundException can be caused by the user account trying to access the file, and simply don't have the necessary access. Under optimal circumstances, the framework should throw a System.UnauthorizedAccessException when this happens. But I have seen the issue in the past when hosting websites on IIS. Make sure that the ASP.NET worker process account (or NETWORK SERVICE depending on which user you are using) has access to all files and folders needed to run the application.


Hope you are doing well. A quick question for you. Does Accpac publish a Web service for sales tax calculation that is similar to that from Avalara or it relies completely on 3rd party vendors for sales tax calculations? In other words, if I am creating an order from an external interface (APIs) can I query a service in Accpac that will calculate and return in the various sales taxes?


Usually you need to assign that user to admin, then run regacc, then reassign them back to being a normal user. This process will register any ActiveX controls that need registering. If your custom solution has any additional controls that Accpac may not know about, then register these also while they are administrator.


Issue: To populate the cost in the viewlist the custom program will have to update the datasource (in the DB table) with the cost and do refreshdata to reflect it in the viewlist. User may change the header costing method option any number of times.


Update the cost in the datasource (DB table) and refreshdata seem to be a bad idea bcoz the user may choose some costing method and close the UI however, the cost will be updated by the custom program which is not be the ideal requirement.


Shall I use the cloned datasource to show the cost values populated and then once user hits a save button then save it back to the original datasource? please advise if my understanding with the datasource clone is not correct.


Hey Steve,

Just wondering if you or your team have done any testing with Accpac running over VMWare View or ThinApp? Terminal Server and Citrix is unfortunately not an option with an existing client expanding. All their App servers are already virtualized with VMWare.


I have managed to figure out most of the issue and everything works fine in my developement environment however as is typical when deploying to the live environment i have errors and they occur when the code hits the init of the ACCPAC session with and access denied error.


We are in the process of prototyping SData to write an interface to 6.0A from our Retail Manager solution. It has taken a while to get something working (we are new to SAGE and 6.0A so this has been a big learning curve for us) and your blogs have been a big help so far so thanks for that.


Using the customers, we are now able to process customer records through the all CRUD stages. We do have a few questions and concerns and hope that you could assist. Our plan was to focus on our interface to SAGE using SData for 6.0A but we are a bit concerned that we may not be able to address all of our requirements. Our main requirement at this stage is to be able to write data back to 6.0A for customers, items, sales orders, inventory transactions and bank transactions but we are struggling to find how to achieve this. We also need to read data back and this seems to be easier to achieve.


You can, but I think its fairly difficult. You need a section in the CPRPT.INI file similar to the ones for the existing report. It might be easier to backup and then modify the existing report, test it by running it from the regular UI, then when you are done rename it and create a section in CPRPT.INI for it, then restore the original report. The good news is that we are currently working to remove all the datapipes from Payroll.


We also had an issue with a new AccPac 6.0A install. Once completed, when we tried to access the SData portal, we received an error indicating that the class com.sage.accpac.swt.sagecrmorderui.server.OEOrdersResourceKind could not be found. I had a look in the oe classmap.xml file and noticed that most of the other resources referred to the com.sage.orion.sdata.servlet.accpac.ViewResourceKind class. So, I changed the oeorders class to point to this class and the system seemed to work ok. So, what is the difference between the 2 classes and have I caused a potential problem by pointing to the base class.


My laptop has the visual 2010 environment and I have a 2008 server that has Sage 300 ERP installed. I ran the WSSetup on my laptop to get access to accpac and the API on the server. I compiled, installed and ran the program on my laptop and the program works as expected. (each time I run it a new quote gets created)


Strange that its an InvalidCastException. Hard to see how passing in four string constants could cause this. You might try opening up the SDK sample in c:\pluswdev\samples\dotnet\vb-Net and see if it has the same problem.


I am writing an interface to the sage desktop using the vb .net framework 4.5 in visual studio 2012. I would like to use the accpacfieldedit control, but get an error whenever I try to access the accpacdatasource:


Hello Stephen,

Thank you for your helpful blog.

We are using Sage accpac since v5.5. We used it at our factory. and currently using v5.6. We have many problems by Day end process. it take a long time.

We run it 3 times a day. and it stop our process 15 mins each time. from last week we enable lot tracking. it face us a big problem, day end process increase to 50 mins each time. ( We used a high performance server/hardware and there is nothing we can do on our server setting)

Would you please help me :

1- is there any way to we rollback and disable lot tracking ?

2- is there any suggestion to decrease Day end process time? ( I read your article on your blog and we test that setting we use costing during posting)

3- If we upgrade to v 6, is there any improvement on Day end process? we have a lot of customization so we are not happy to upgrade to new version while we not sure about performance improvement .


It would depend on what your problem actually is. We do take performance problems seriously and there are always improvements in each new version (even each product update). But for your situation, it might be worth setting up the new version on a test system and giving it a try.


I encounter some problems when using macro in vb6. Hope you can guide me to the correct direction.

1. Macro create journal fail, because no value in optional field. Although the optional field has been set to not required.

2. Auto create CN fail, because item inventory cannot be negative. CN should be adding stock.


I would try macro recording these operations from the regular UIs and compare what you get with your code to see if you are missing something. It might be you just need to compose some more Views or need an extra process call.


1. I actually copied a recorded macro from Accpac, but using different version 5.4A. In production we are using Accpac 6.0A. However I did change all the declaration. Not sure whether this is the reason.


Perhaps have a look at this article: -sdk-or-not-to-sdk/. Generally the COM API or .Net API are the recommended way to go. These APIs can do anything in the system. There are Web Services interfaces with SData but the API is only on a subset of the system so you could get stuck depending on what you are trying to do.


You may have to contact customer support on this one. Or you could try the COM Spy program that is in the tools under Sage 300 from the Start Menu. Try spying on different things to see if you can get a more helpful error.

3a8082e126
Reply all
Reply to author
Forward
0 new messages