SharpDevelop Forms Designer not working in Revit 2021

SharpDevelop Forms Designer not working in Revit 2021

sragan
Collaborator Collaborator
7,015 Views
24 Replies
Message 1 of 25

SharpDevelop Forms Designer not working in Revit 2021

sragan
Collaborator
Collaborator

In Revit 2020, I can create a new C# module, create a new C# Macro, go to Project, Add New Item, and add a WPF C# Window which is named Window1.

 

If I then select the Window1 I can view the code.  Clicking the "Design" tab at the bottom of the code window shows a preview of the window.

 

In Revit 2021, I get no preview.  Just an error message:

 

System.NullReferenceException: Object reference not set to an instance of an object.
at ICSharpCode.FormsDesigner.Services.TypeResolutionService..ctor()
at ICSharpCode.WpfDesign.AddIn.MyTypeFinder..ctor()
at ICSharpCode.WpfDesign.AddIn.MyTypeFinder.Create(OpenedFile file)
at ICSharpCode.WpfDesign.AddIn.WpfViewContent.LoadInternal(OpenedFile file, Stream stream)
at ICSharpCode.SharpDevelop.Gui.AbstractViewContentHandlingLoadErrors.Load(OpenedFile file, Stream stream)

 

Is there any fix?  

0 Likes
Accepted solutions (1)
7,016 Views
24 Replies
Replies (24)
Message 2 of 25

joshua.lumley
Advocate
Advocate
Accepted solution

Use the Community Edition of Visual Studio instead of SharpDevelop.

0 Likes
Message 3 of 25

stever66
Advisor
Advisor

I did think of that, and I could copy and paste code back and forth between Sharp and VS, getting forms and such to look right in VS, and then pasting back into Sharp.

 

But we shouldn’t have to do that.  And it seems like if SharpDevelop has a bug in 2021 that wasn’t there before, that AutoDesk would want to fix it.

 

But I guess I really have a bigger concern:  Since SharpDevelop is no longer officially in development, or supported,  does that mean it will just develop more bugs and things that don’t work with each successive version of Revit?

 

Or worse:  Is it possible the Macro Editor will just be omitted from future versions of Revit?

 

I sure hope not.

0 Likes
Message 4 of 25

sragan
Collaborator
Collaborator

Well, I guess I'm the only one worried about Sharp Develop in Revit going the way of the dinosaur.

 

But anyhow, I still can't get Sharps Form Designer to work.

 

@joshua.lumley   

The odd coincidence is that I'm actually trying to go through your 5 secrets of coding, and this is where I'm getting stuck.   Step 7.4, I can't add the buttons to a blank form without the designer.   

 

I did try your suggestion of using Visual Studio, and at first the Form Designer didn't seem to work there either.    (I started the project with a Macro, and opened it in VS by draging the .sln file into VS. )   

 

But a search online revealed a post about the forms designer not working if there is more than one class in the project.  After deleting all other classes, the the designer suddenly started working.  No luck trying this with Sharp. 

 

I guess I'll have to add the buttons with the designer in VS, and copy the added code back to my Sharp Macro.

 

0 Likes
Message 5 of 25

sragan
Collaborator
Collaborator

Ugh... After trying to reopen the project in Sharp, I get an error message about missing .cs files.   

 

Apparently, deleting a class in VS deletes files even if you don't save the project.   

 

It looks like I'm back to step #1 to try again. 

0 Likes
Message 6 of 25

joshua.lumley
Advocate
Advocate

Sharp develop is only good for initiating projects. Watch this video which is #2 in the secrets series:

https://www.youtube.com/watch?v=S0MPxBRL7c0 

0 Likes
Message 7 of 25

joshua.lumley
Advocate
Advocate

The platform target I use is x86 not x64 for child binaries.  This often fixes it when the designer isn't working.

0 Likes
Message 8 of 25

sragan
Collaborator
Collaborator

@joshua.lumley  

I really appreciate your videos and examples.  They're very helpful.  I did eventually make it through your first video and the PDF handout.   

 

Since I couldn't get the Sharp Forms Designer to work, I had to add the form buttons in VS, and copy the code back (with  few edits).   I've attached a couple of text files with the code just in case anyone else has the same issues.   

 

(BTW, just in case anyone else also has this problem, I noticed the PPF handout is missing a step - copy and paste "016 Drag on Space Elevator" into a new class called Class2.   I couldn't figure out why it wouldn't compile until I watched the video again. )

 

Also, I completely disagree about Sharp Develop only being good to set up projects.  It has some limitations, but anyone can always edit, build, and test within 2 seconds with SharpDevelop.   It's great for beginners, because it takes the least amount of time and effort to get some code up and running.   I prefer to test and edit all my code within Sharp, and then just copy and paste into VS, making the few edits necessary for things like uidoc and doc.   And you seem to have proven Sharp Develop can do some things its not supposed to do - like external applications, ribbons, and ribbon buttons.

 

Thanks;
Steve

Message 9 of 25

sragan
Collaborator
Collaborator

I almost forgot to mention just in case anyone else needs to use the Sharp Develop Forms Designer in Revit 2021:  For some reason, if I open Revit 2020 first, and open a sharp develop edit window in 2020 (by selecting a macro and then selecting edit), then open 2021 Revit, then the Sharp Develop Forms Designer works.   I've tried this several times.

 

 

Message 10 of 25

joshua.lumley
Advocate
Advocate

Yes Sharp develop is a fully functioning IDE and looks clean...faster to. With VS I may have falling in love with the Vertical Brace lines and the dark theme. VS also it supports installer projects for making MSI.

Message 11 of 25

GaryOrrMBI
Collaborator
Collaborator

I wish that you hadn't marked this as solved... it means that no one will look at it and see that I am having the exact same problem... been fighting it for a full day.

 

But your comment:

 


@sragan wrote:

I almost forgot to mention just in case anyone else needs to use the Sharp Develop Forms Designer in Revit 2021:  For some reason, if I open Revit 2020 first, and open a sharp develop edit window in 2020 (by selecting a macro and then selecting edit), then open 2021 Revit, then the Sharp Develop Forms Designer works.   I've tried this several times.

 

 


works here as well...

Thank you.

 

Meanwhile, since this is now a know and proven issue I hope the developers get in and take a look at the problem. Hopefully it will get fixed for 2021 and, if not, hopefully it will get fixed before 2022 hits the streets here in a bit...

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
Message 12 of 25

GaryOrrMBI
Collaborator
Collaborator

To further this a bit... Just opening and closing a macro in SharpDevelop for Revit 2020 isn't enough... You have to keep it open for the 2021 version of forms designer to work correctly.

 

 

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 13 of 25

RPTHOMAS108
Mentor
Mentor

Probably this is a main issue for forms.

 

For WPF you can add the Window and copy over the Xaml, it will sill build if you add a reference to system.xaml. The designer still doesn't work but that can be done elsewhere. Not much you can do for windows forms however.

 

It is a shame that SharpDevelop as an IDE seems to be on it last legs, probably there were updates to redistributables elsewhere due to .net and it isn't coping well with changes. I don't think it is as supported as it was so will be interesting to see what is decided going forward.

 

There is an argument for dropping it and instead supporting RPS inherently since a lot of ad hoc developers seem to work with that these days.

0 Likes
Message 14 of 25

GaryOrrMBI
Collaborator
Collaborator

Well, they need to stop that talk. First they gave us VSTA as an IDE, then decided that it was too much of an effort to keep up with by themselves and took it away, then they gave us SharpDevelop as an IDE, now you say that they're talking about taking that away as well?


I don't know anything about the new one that you mentioned but there is a very good reason that we need an IDE, so we can actually test our code in real time. For many the IDE is all they need as they're just developing for themselves or perhaps only a couple of team members so they simply share the macros.

 

I'm not even going to get into a sidebar of Dynamo and it's quirks and limitations (unless you know a very specific programming language and can understand and use that scripting interface)

 

For people like me (that may go years between trying to write any additional functions) it is important to stay in an , at least somewhat, familiar language and environment. I struggle enough as it is trying to translate all of the C Sharp examples and such to the VB that I am somewhat familiar, but I simply can't take the time to fully immerse myself in a new language... I use VB because VBA was the IDE of choice (for many, many applications) when I started trying to hack things together more years ago than I would care to admit 🙂

All I'm trying to do is simplify a few things for myself and my co workers. I simply can't dedicate myself full time to learning all of the ins and outs of all of the different programming interfaces.

 

Autodesk, if you're listening, please take this into consideration.

 

-G

 

 

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 15 of 25

RPTHOMAS108
Mentor
Mentor

I don't have any inside knowledge on these things but I can see the signs I think. The band is still playing but there is water on deck up to their ankles. Could be wrong perhaps it is a simple fix that will be fixed.

 

I to would like SharpDevelop to continue but this is a 3rd party component and I think VSTA was a Microsoft maintained thing. Still available for AutoCAD but you have to install it (last time I wondered about it). The .Net languages have been around for quite a while now Excel/Word/AutoCAD etc. all support them. I used them in AutoCAD over a decade ago now.

 

Probably most Revit developers these days are either those that use Revit API with one of the .Net languages or those that use some form of Python over that. I tend to wonder what the district features of SDE are that you can't get with a free version of Visual Studio? Probably the only distinct feature is to package a macro and have it delivered with a project file (that is more to do with how Autodesk implement it). 

 

The developers of SharpDevelopment are still offering its components in jigsaw fashion on github. There is a VB/C# code converter there from SharpDevelop. There is also the various designers that SDE uses but I think they've taken a step back from providing all of those items as an integrated thing (can't really blame them given the emergence of Visual Studio Code or even VS Community edition).

 

0 Likes
Message 16 of 25

GaryOrrMBI
Collaborator
Collaborator

The reason that I use an IDE is just that... it's Integrated with the application that I developing for.

 

Coding, for someone like myself, is a step by step process... do this one thing, build it, test it... do the next thing, build it, test it... repeat several times per day (or hour even).

 

With Visual Studio I can't do that. So I am building the solution step by step in the IDE, then copying the code into Visual Studio (and adding the menu constructors and whatnot there) where it will eventually live to distribute as a functioning application to the rest of the company.

 

I know that Autodesk walked away from VSTA simply because they didn't want the headache of following Microsoft's rules for using and integrating it. I, personally wish they would do what they are constantly telling us to do... suck it up and deal with it 🙂 and reintegrate VSTA as the IDE for all Autodesk apps with an IDE (primarily Autocad and Revit but...)

 

Actually, the Autocad based products are still using 2012 VBA as the IDE (the last official version of VBA that was left behind by Microsoft in favor of the newer concept of VSTA which allowed for more programming languages to be used so a person wasn't stuck with Visual Basic and could use C Sharp, etc or even mix code types in the same solution).

 

I would work exclusively in Visual Studio and not care about an IDE if they would provide us with a simple, quick, and easy to use and understand, reloading mechanism for applications written in VS that gives us the same ability to just rebuild the solution, then run the new build.

 

-G

Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)
0 Likes
Message 17 of 25

Organon
Advisor
Advisor

@sragan ,

 

Hi,

 

It also works by just opening the SDA.exe file from C:\Program Files\Autodesk\Revit 2020\SDA\bin and then opening Revit 2021.

 

Regards,


Arquitectura | Análisis CAD & BIM | Diseño Paramétrico | Programación
BIM-METADATA | LinkedIn | YouTube
Message 18 of 25

H.echeva
Advocate
Advocate

Well...

I have the same problem. Unfortunately, opening Revit 2020 (and leaving the SD window open) and then Revit 2022 doesn't work form. In fact, now using previous versions of Revit I can't use forms anymore!

Opening SDA.exe from C:\Program Files\Autodesk\Revit 2020\SDA\bin does nothing for me either (no window appears).

Does anyone have found another solution?

Sharp Develop is great to make quick tests or quick macros. Using Visual Studio is too clumsy for these kind of things.

Message 19 of 25

Organon
Advisor
Advisor

@H.echeva,

 

Hi,

 

Try this:

 

  • Close all Revit products.
  • Open SDA.exe from C:\Program Files\Autodesk\Revit 2020\SDA\bin . No window appears, and it's okay (it is opened as a background process).
  • Open Revit 2022 and then the macro manager and edit your code.

Regards,


Arquitectura | Análisis CAD & BIM | Diseño Paramétrico | Programación
BIM-METADATA | LinkedIn | YouTube
0 Likes
Message 20 of 25

H.echeva
Advocate
Advocate

I know my reply is very late but unfortunately, this didn't work.

Edit: I had to go back to Revit 2018 to make this work. Unfortunately at one point Revit 2018 won't be available for me so I can't rely on this solution.

0 Likes