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: 

Visual Studio Reporting many errors after Changing the Reference Files to 2022 version

6 REPLIES 6
Reply
Message 1 of 7
lucas.dejongPTZ3P
504 Views, 6 Replies

Visual Studio Reporting many errors after Changing the Reference Files to 2022 version

Hey Forum, (and maybe Mr. @naveen.kumar.t in perticular as I've seen many great solutions from him),

I have created a Revit add-in using the RevitAPI.dll and RevitAPIUI.dll files as references from the Revit 2020 folder.  Working well for Revit up to 2021, but not for Revit 2022.  I understand there have been some API changes in Revit 2022.  So in order to update my add-in for Revit 2022, i removed the references, and added the version 2022 .dll files.  I got a few errors in my code because of the API changes, but I was perfectly able to fix those.   

When I build my solution, this is where the trouble starts:  I get errors, many errors, pretty much all of them saying: 

 

CS0234 The type or namespace name 'Revit' does not exist in the namespace 'Autodesk' (are you missing an assembly reference?)

this error shows 594 times, with different things missing, but all of them being types or namespaces that are absolutely available.  When I double click the error, the class it is in opens, and the error disappears.  I can do this for all of them, but building the solution still fails, and when I save and close the class-files in VS, then build the solution again, all the errors come back.

 

There's probably a single setting or line that I need to change, but I cannot figure out what that is.  Please help.

 

Thank you,

6 REPLIES 6
Message 2 of 7

Hi @lucas.dejongPTZ3P,

 

Check the target .NET Framework used in the project, for R2020 it would be Net Framework 4.7.

For Revit 2021 - Revit 2023 the target Framework should be Net Framework 4.8

 

Depending on the actual code used in you're project of the Revit API used Net 4.7 could work.

 

- Michel.

 

Quick Reference of Frameworks per Revit version.

Revit 2017-2018 => .Net 4.6

Revit 2019-2020 => .Net 4.7

Revit 2021-2023 => .Net 4.8

Message 3 of 7

Hey @TripleM-Dev.net ,

 

Thanks for the reply.  It did seem like that helped, but I now have different errors.  This time I have 580 errors pointing at xaml files of the WPF windows that the app uses, saying that "The type '[wpf-window or wpf window control]' already contains a definition for '[controlname]' or a control is implemented more than once.   something seems to be double.  But I can not actually find something double.   Any idea?

 

Thank you!

Message 4 of 7

Hi @lucas.dejongPTZ3P,

 

I have setup a multiversion Solution for R2017-R2023 in which I setup everything.

 

For R2022 API I have references to: (with Copy Local = false), these should all be from the R2022 API!

- AdWindows.dll

- RevitAPI.dll

- RevitAPIIFC.dll (optional I think, depending of used code)

- RevitAPIUI.dll

- UIFramework.dll

- Xceed.Wpf.AvalonDock.dll (optional, related to the Revit tabs)

 

Also check if the following are referenced of the .NET:

PresentationCore / PresentationFramework / System.Xaml / System.Xml

WindowsBase / WindowsFormIntegration

 

- Michel

 

 

 

 

Message 5 of 7

Hey @TripleM-Dev.net Michel,

 

I checked the references, I did not have WindowsFormsIntegration in there, but after adding it, the problem is not gone.  It looks very much like my WPF Windows are called twice/double, but I cannot seem to find the class or code where that happens.  Cleaning/Rebuilding/Restarting do not help.   Next I think I'll create a WPF test window, to see if it is accepted without throwing errors.  Any other suggestions?

 

Thanks

Message 6 of 7

Nope, the test window had the exact same issue:  it is somehow called twice, as each control is already there when it is called, and there is an ambiguity between the control and the same control again.

 

Help?

Message 7 of 7

Alright, so in the end it turned out that my obj, bin and packages folders were included in the project, which caused the wpf windows to be called twice.  The solution is working now, thanks all!

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community