Unhandled exception : 'Could not load type 'S7.Net.Plc' from assembly 'S7.net, Version=1.0.0.0, Culture=neutral,

Yash89 0 Reputation points
2023-05-09T15:43:25.8266667+00:00

Hello All,

I am facing an issue with this exception and need your support to resolve.

S7.Net.Plc' from assembly 'S7.net, Version=1.0.0.0, Culture=neutral,

I am creating a windows form using c# to make a connection between S7 300 PLC and this form . Hence I have insalled S7netplus package which is provided by Siemens to make the connection.

But as I run the Code I get this exception .

Developer technologies | Visual Studio | Other
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2023-05-10T08:27:09.0833333+00:00

    Hello @Yash89 ,

    Welcome to Microsoft Q&A forum.

    Please first try to remove NuGet cache by removing folders(packages) in C:\Users\username\.nuget\packages. After that remove the hidden .vs folder, bin and obj folders in your project folder, and rebuild your project.

    If it doesn’t work, please try to run all commands mentioned here(Clearing local folders) to clean NuGet cache again and then rebuild your project.

    Please also open this folder %windir%\Microsoft.NET\assembly and make sure that S7netplus package isn’t included in any three folders(GAC_32, GAC_64, GAC_MSIL).

    Besides, may I confirm several information with you to check further:

    1. Is your project based on .NET or .NET Framework? And could you share us the detailed version of the based framework for example .NET 7.0.
    2. Is there any other project included in your solution? And is there any reference between projects?
    3. Are you using the latest version of S7netplus package?
    4. Did you install multiple versions of S7netplus package?
    5. How did you use S7.Net.Plc in your project, is there any code snippet we can check further?
    6. Does this issue appear in a newly created project?

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.