Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly error I get in Revit

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
oguzkomcu
690 Views, 16 Replies

Assembly error I get in Revit

revit.png

 

As you can see, I'm not actually missing a using statement. When I searched for this problem on the internet, I saw that it was related to the .Net Freamwork version. When I upgraded my class library to 4.8 the errors went away. Later, when I ran my class library that was working on .net core, which was working before, I did not get any namespace errors. Later, I ran revit, but I got this error on both occasions.

 

Error : System.TypeLoadException Could not load type ' RevitGltfDeneme3.App ' from assembly ' RevitGltfDeneme3 , Version 1.0.0.0 , Culture = neutral , PubliKeyToken = null " .

 

When I researched the error I was told that I could fix it with Gac or that I should delete and recompile. When I deleted and reinstalled, I got the same error again. I couldn't find exactly how to solve it with Gac. How can I resolve this error.

16 REPLIES 16
Message 2 of 17
nice3point
in reply to: oguzkomcu

Try using templates, when creating an add-on, select the UI - None option https://github.com/Nice3point/RevitTemplates. This will solve your Assembly reference problems. By the way, unsubscribing from the Idling event should occur at the beginning of the method and not at the end, in case of an exception, unsubscribing will not occur. The use of Static fields is also undesirable.

Message 3 of 17
Kennan.Chen
in reply to: oguzkomcu

My question is, why .net core?

Message 4 of 17
nice3point
in reply to: Kennan.Chen

.Net SDK, not .Net Core. TargetFramework for Revit must use the old one, net48. Revit will not work with plugins written in .Net5+

Message 5 of 17
Kennan.Chen
in reply to: oguzkomcu

You should choose proper .net framework version that your add-in is targeting.

Revit itself has a targeting .net framework version -> Version A

Your add-in has a targeting .net framework version -> Version B

Version B must be equal with or lower than Version A

if Version B is greater than Version A, your code compiles but will be failed at runtime.

Message 6 of 17
nice3point
in reply to: oguzkomcu

netstandard 2.0 and netstandard 2.1 have a different set of libraries

Message 7 of 17
oguzkomcu
in reply to: oguzkomcu

I did the install in your repo.
When I wanted to install RevitTemplates, I got an error like this.

 

 

Error : Error: Failed to load template from "C:\Program Files\dotnet\templates\3.1.26\microsoft.dotnet.winforms.projecttemplates.4.8.1-servicing.22281.3.nupkg(/WinFormsLibrary-CSharp/.template. config/template.json)".

 

 

I have installed the latest version of .Net Sdk. Then when I tested it in Revit again, I got the same error again.

I don't know, is there an error in my addin file?

 

 

<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>Application RevitApiDeneme</Name>
<Assembly>C:\Users\oguzhan komcu\source\repos\RevitApi_MyApiProject\RevitApiDeneme\obj\Debug\net6.0\RevitApiDeneme.dll</Assembly>
<FullClassName>RevitApiDeneme.App</FullClassName>
<ClientId>bd9e2e87-544c-49c6-a417-c9af26b400bb</ClientId>
<VendorId>TBC_</VendorId>
<VendorDescription>oguzhan</VendorDescription>
</AddIn>
</RevitAddIns>

Message 8 of 17
nice3point
in reply to: oguzkomcu

The template already has a generated Addin file. Don't try to use net6.0 for development, Revit won't be able to load required libraries into the AppDomain
Message 9 of 17
oguzkomcu
in reply to: oguzkomcu

Error: Failed to load template from "C:\Program Files\dotnet\templates\3.1.26\microsoft.dotnet.winforms.projecttemplates.4.8.1-servicing.22281.3.nupkg(/WinFormsLibrary-CSharp/.template.config/ template.json)".

 

I keep getting this error. I tried this template in both .net6.0 and .net 4.8 but got the same error in both. When I try other solutions, I still get the same error in my plugin running on .net freamwork 4.8.

Message 10 of 17
nice3point
in reply to: oguzkomcu

What are you using a winforms template targeting .Net Core 3 for?
Message 11 of 17
Kennan.Chen
in reply to: oguzkomcu

I've got totally confused about what you want to achieve. Why do you want to involve .NET Core or .NET 6. Can you provide some more business scenarios?

Message 12 of 17
oguzkomcu
in reply to: oguzkomcu

My main goal is to convert the desired .rvt file to gltf format in line with the request from my own API application. I want this export process to be done directly when Revit is opened. In another post from From, I got these codes and applied them. I created this in .net freamwork. I got a namespace error due to the version problem and I updated my version to 4.8. But when I wanted to run this plugin in Revit, I got the first error I showed up. The solutions you gave didn't work well or am I missing something?

Message 13 of 17
oguzkomcu
in reply to: nice3point

oguzkomcu_0-1658487586978.png

First of all, I'm sorry because of my own mistake and inexperience, I couldn't upload your templet, but now I created a project with templet. I placed my own code in the Application class. Then I got these errors.

Message 14 of 17
nice3point
in reply to: oguzkomcu

@oguzkomcu Just try to use the templates from the link above, how to install and how to use open the WIKI section on the project page
Message 15 of 17
nice3point
in reply to: oguzkomcu
Message 16 of 17
oguzkomcu
in reply to: oguzkomcu

Thanks for your help. I was able to open the Revit file.

Message 17 of 17
oguzkomcu
in reply to: nice3point

Why can't I choose revit.exe to debug the class library that comes with this template? Is there a different way that I don't know?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report