CreateInstanceAndUnwrap() - Netduino 2 (and Netduino 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

CreateInstanceAndUnwrap()


  • Please log in to reply
15 replies to this topic

#1 AlfredBr

AlfredBr

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationConnecticut, USA

Posted 16 December 2010 - 02:56 AM

Is CreateInstanceAndUnwrap() implemented in the Netduino+? I've tried using it and even the simplest example throws System.NotImplementedException.

#2 Miha Markic

Miha Markic

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationNova Gorica, Slovenia

Posted 17 December 2010 - 09:28 AM

Is CreateInstanceAndUnwrap() implemented in the Netduino+?

I've tried using it and even the simplest example throws System.NotImplementedException.


I doubt it, why would you need it?

Miha Markic, Microsoft MVP C#
Righthand .net consulting and software development
http://blog.rthand.com/


#3 AlfredBr

AlfredBr

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationConnecticut, USA

Posted 17 December 2010 - 01:49 PM

I doubt it, why would you need it?


It's useful for demand loading an assembly into an AppDomain. There are discussions in other threads about using it to load an assembly from the microSD card. (and since I just got my Netduino+, I thought I'd give it a try.)

#4 Miha Markic

Miha Markic

    Advanced Member

  • Members
  • PipPipPip
  • 74 posts
  • LocationNova Gorica, Slovenia

Posted 19 December 2010 - 02:59 PM

It's useful for demand loading an assembly into an AppDomain. There are discussions in other threads about using it to load an assembly from the microSD card. (and since I just got my Netduino+, I thought I'd give it a try.)


Looking at .NET MF v4.1 sources it seems actually implemented. Does your class have a parameterless constructor?

Miha Markic, Microsoft MVP C#
Righthand .net consulting and software development
http://blog.rthand.com/


#5 AlfredBr

AlfredBr

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationConnecticut, USA

Posted 22 December 2010 - 07:36 PM

Good call...I'll try tonight.

#6 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 24 December 2010 - 10:31 PM

I find it odd that this issue is not being addressed by someone on the Secret Labs team. Why is that?

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 December 2010 - 05:10 AM

I find it odd that this issue is not being addressed by someone on the Secret Labs team. Why is that?


Hi Fabien,

It is being worked on; my apologies that I didn't pitch in earlier in the thread... I've been taking notes and updating our internal ticket while we build a few good repro cases and debug into the .NET MF core.

We're pretty short-staffed for the holidays and we're working on the v4.1.0.6b2 and v4.1.1.0a4 updates...but I should have more info during the holidays. I will post more info as soon as I have it.

Thank you very much for your enthusiasm and for helping push the boundaries of the platform...

Chris

#8 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 30 December 2010 - 12:01 AM

Just closing the loop: I figured out how to load assemblies dynamically and wrote post about it on my blog: http://fabienroyer.w...ith-a-netduino/

Cheers,
-Fabien.


#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 30 December 2010 - 05:32 AM

Thank for posting your results, Fabien. We should put together a framework for easy loading of dynamic code. Interestingly, it appears that assemblies may need to be loaded into the main appdomain on .NET MF before they can be used in secondary domains. Chris

#10 Charles

Charles

    Advanced Member

  • Members
  • PipPipPip
  • 192 posts

Posted 31 December 2010 - 12:57 AM

Just closing the loop: I figured out how to load assemblies dynamically and wrote post about it on my blog: http://fabienroyer.w...ith-a-netduino/

Cheers,
-Fabien.


Awesome! I don't yet have a use for this, but I'm sure I soon will... :)

#11 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 03 January 2011 - 08:30 PM

Thank for posting your results, Fabien. We should put together a framework for easy loading of dynamic code.

Interestingly, it appears that assemblies may need to be loaded into the main appdomain on .NET MF before they can be used in secondary domains.

Chris


You're welcome :)

I think it would be great to have a standard way of loading dynamic code efficiently on the netduino. However, I also think that documentation alone would go a long way and would not increase the footprint of the firmware ;-)

Cheers,
-Fabien.

#12 Valkyrie-MT

Valkyrie-MT

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts
  • LocationIndiana, USA

Posted 05 January 2011 - 02:26 AM

I figured out how to load assemblies dynamically...


Awesome! This was on my To-Do list! Thanks Fabien!

-Valkyrie-MT

#13 AlfredBr

AlfredBr

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationConnecticut, USA

Posted 17 January 2011 - 04:47 AM

:) Thanks Fabien :) for figuring out how to load assemblies into the current AppDomain. Your technique works great!

Have you (or anyone else) had any luck loading and executing assemblies in a secondary domain? I think loading into an AppDomain other than the current domain is necessary in order to support unloading the AppDomain after the assembly has served its purpose -- i.e. so you can reclaim that memory for other uses (like loading another, different assembly).

Chris Walker commented that an assembly needed to be loaded into the current AppDomain before it is loaded into a secondary domain. (If this is the case, using a secondary domain may defeat the purpose or even make things worse from a memory use standpoint.)

I have not yet been successful in loading an assembly into a secondary domain, but I'll keep trying and post my results.

#14 Fabien Royer

Fabien Royer

    Advanced Member

  • Members
  • PipPipPip
  • 406 posts
  • LocationRedmond, WA

Posted 19 January 2011 - 08:59 PM

:) Thanks Fabien :) for figuring out how to load assemblies into the current AppDomain. Your technique works great!

Have you (or anyone else) had any luck loading and executing assemblies in a secondary domain? I think loading into an AppDomain other than the current domain is necessary in order to support unloading the AppDomain after the assembly has served its purpose -- i.e. so you can reclaim that memory for other uses (like loading another, different assembly).

Chris Walker commented that an assembly needed to be loaded into the current AppDomain before it is loaded into a secondary domain. (If this is the case, using a secondary domain may defeat the purpose or even make things worse from a memory use standpoint.)

I have not yet been successful in loading an assembly into a secondary domain, but I'll keep trying and post my results.


Hi Al,


You're welcome :)

I have not spent much time investigating loading assemblies into a secondary domain yet.

As far as unloading/reloading assmblies goes, I solved the problem like this: when the SD card is swapped out and a new one is inserted into the reader, I generate an interrupt which forces a reset of the netduino. At that point, the app re-initializes itself and loads the new version of the assembly from the SD card. It's simple and reliable :) I realize that this method may not fit all scenarios.

I hope this helps.

Cheers,
-Fabien.

#15 Bendage

Bendage

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts
  • LocationIrvine, CA

Posted 13 April 2012 - 03:08 AM

Thanks to Fabien's blog I am able to load assemblies dynamically. However is there any way to debug these assemblies? Kind of a pain popping out the memory card and trying a change that doesn't work.... over and over.

#16 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 03 April 2013 - 06:26 AM

Couple of questions,

 

Is is possible to load an assembly in a secondary domain now?

 

How about Bengage's question, is it possible to debug the code of the assembly being loaded or not?

 

Thanks






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.