Grasshopper

algorithmic modeling for Rhino

I'm using normal sintax to build my plugins icons (VB) .I add my icon (24x24 PNG image maked with Illustrator and Photoshop) to resources and then I add this lines to my code: 

 

[...]

Protected Overrides ReadOnly Property Internal_Icon_24x24 As Bitmap        

Get            

Return My.Resources.icon    

End Get    

End Property

End Class

 

 

No errors in compilation, but icon and tab doesn't in GH but the plugin loads correctly.

 

I'm using Visual Studio 2010.

 

Best Regards.

 


 

Edit:

 

The solution to this problem is to compile GHA libraries against the .NET framework 3.5 or lower. Grasshopper is Rhino4 compatible meaning .NET 4.0 or higher will not work.

Views: 2004

Replies to This Discussion

david asked you to put a breakpoint to debug and see if there is a exeption! 

david: "did you put a breakpoint on that line (Return My.Resources.ICON)? Is there an exception that gets thrown when you hit it?"

best to]

Did you put a breakpoint on the line to see if it runs without exceptions? Are you able to debug your code? If not, can you at least post a screenshot of your project Resources page and the exact image file you're linking?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

No, I have just added one and there is no exception :S

 

I'm able to debug, but there is no exceptions in that line (indeed there is no exception in all code)

 

I'm attaching the icon and a screenshot.

 

Thanks for your help :)

Attachments:

Another shot:

 

 

Attachments:

Darnit, can't work it out yet. 

 

Try the following, remove the image from the resources and replace the contents of the Internal_Icon_24x24 property with code. Something like this:

 

Dim icon As New Bitmap(24, 24, Imaging.PixelFormat.Format32bppArgb)

Dim G As Graphics = Graphics.FromImage(icon)

G.Clear(Color.Transparent)

G.FillEllipse(Brushes.DarkRed, New Rectangle(4,4,16,16))

Return icon

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 

Perfect!, now I can see a red circle in my icon place in GH UI.

 

What's wrong with my PNG file or sintax? How could i get my icon working?

 

Best Regards.

Well, we've narrowed it down to a problem with the icon image file or the project resources. You're doing this in Visual Studio 2010 with which I don't have much experience. I do know that .NET 4.0 has a different mechanism to access resources (it's localized and tends to raise AssemblyResolve events). This was actually a bug in Grasshopper a while back that only occurred in Rhino5 (as Rhino5 loads .NET 4.0).

 

Are you compiling your project against the 4.0 framework, or the 3.5 one?

 

Does this bug happen in both Rhino4 and Rhino5?

 

Is there anything printed in the command line that might indicate Grasshopper is called upon to resolve an assembly?

 

 

Sorry for asking so many questions. I just don't know where to start looking for this.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I've just looked and I have seen .NET Framework 4...Must I change it to 3.5?

 

I'm reporting the bug from Rhino4. I've installed Rhino5 but 64bit version...I can't check now the bug on it.

 

 

I think we got it. I can read this after call GH in command line:

 

Assembly Resolver initializedAn exception occured during GHA assembly loading:  Path: *:\Visual Studio 2010\Projects\*_001\*_001\bin\*_001.gha  Exception System.TypeLoadException:   Message: No se puede cargar el tipo 'System.Runtime.Versioning.TargetFrameworkAttribute' del ensamblado'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

 

Christ I hate that they localized the error messages.

 

Rhino4 loads .NET 3.5. If you intend to give your code to people who will run it on Rhino4 you'll need to target the 2.0, 3.0 or 3.5 framework.

 

Grasshopper itself is build against 3.5

 

I sincerely hope the problem goes away after this. Have a look at this page. It seems to say that the TargetFrameworkAttribute is new in .NET 4.0 which would certainly explain why the loading fails.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Me too...I understand perfectly error messages in english, but translate from spanish to english with no-exact words makes search in forums, google, etc, a painfull task.

 

Ok, I'll change to 3.5. Is this the best version of NET. target for general purpose plugins?

 

Best Regards :)

Yes, 3.5 is an improvement over all previous frameworks. But it is a minor improvement. In fact, 3.0 and 3.5 should have been called 2.1 and 2.2, but I think MS marketing intervened.

 

4.0 is a much larger step forward, but due to the young age of this version it is still not supported in many environments.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

You are the man :D

 

Icons working changing to .NET 3.5

 

Thanks for your valuable time :)

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service