EWR sample not work

ExtendedWeakReference Sample loads and seems to runs fine. It just does not Increase the count on my mini between Runs. I was reading another post on this, but search does not find for me now. Solution with just MS dlls as-is should still work?

EWR saves the data on idle process. So after you save them, give the device some idle time. What device are you using?

Are you sure the mini supports EWR? I think only the Cobra does.

I didn’t realize you are suing FEZ Mini. EWR is only available on FEZ Cobra.

If the EWR code runs on the mini, but does nothing, then might a CLR_NOTSUPPORTED_EXCEPTION be appropriate?

Good question! Some internal Microsoft methods may call EWR and then users will see the exception and be scared! So, we made it in a way where no exceptions are shown for EWR but it is in fact not implemented

“Good question! Some internal Microsoft methods may call EWR and then users will see the exception and be scared! So, we made it in a way where no exceptions are shown for EWR but it is in fact not implemented”

ooo. With much respect (as such a great job on everything). That is not so much a good design in .Net in general for any user. Professional or beginner. Hidding or “swallowing” exceptions only leads to confusion and other bugs later in a program. Fail as early as possible is a good rule. During development and testing, we all expect exceptions when something can not or will not work as expected in the api contract so we can fix, learn, submit bug to MS :-), or continue on.

I totally agree with you but there is an exception for every rule. After looking into it in details and studying different scenarios, we decided that it is best for users to complete it that way… otherwise you will always see exceptions no matter what you do even if you do not use EWR…and this is not fun at all especially for beginners.

I’m sorry to bump such an old Thread, but it contained useful information and I’ve got a question about EWR.

It’s stated above that the FEZ Cobra needs some time to save the config to its EWR memory.
Is there anything else I should know about saving to EWR?
I’ve tried to save some data to it in my program and afterwards reset it via the reset button, forcing a WD reset, pugging it out and in and lastly rebuilding the project in Visual Express.
Only the last option has resulted in the data actually being saved. Is this because it need more time to save if I force a reset through the hardware, or is something else going wrong?

It is not “time” but “idle time” is what you need. I believe software reboot forces the data to be saved.

So is it possible to do that by setting up a WD with a delay of about 5 seconds after I set the Target?

I do not understand

I think he is talking about setting watchdog timer

Yeah, sorry. I was talking about this line:


I hoped this would reset the FEZ after 5 seconds, thus saving the EWR Target.
But after the reset my Target is wiped.

Lets us start from zero…

What device are you using?

Where is the code that demonstrate what you are doing?

I am using an EMX FEZ Cobra, Version
I am trying to save some network and communication settings in it’s EWR.
To do this I type in the settings in my webpage and post them into the FEZ.

    program.SaveEWR(waarden[0], ip, sub, gate, waarden[13].Equals("TCP"), baud, parity, dataBits, stopBits);

SaveEWR does this:

private ExtendedWeakReference ewr = ExtendedWeakReference.RecoverOrCreate(typeof(ProjectSettings), 0, ExtendedWeakReference.c_SurvivePowerdown);

public void SaveEWR(...)
    ProjectSettings settings = new ProjectSettings();
    settings.ProjectName = name;
    settings.ipAddress = ipAddress;
    settings.dataBits = dataBits;
    settings.stopBits = stopBits;
    ewr.Target = settings;
    SettingsSet = true;

Edit: I just tried ExtendedWeakReference.c_SurviveBoot, to no success.

As you see my code first of all saves the settings in SaveEWR() by setting ewr.Target.
After that a Watchdog is created to reset the device after 5 seconds. This doesn’t save the settings however.

The only way I can save into the EWR at the moment is to comment out the WD line of code and rebuild the solution in Visual Express.

Start with the example in Microsoft NETMF SDK. Is simple and explains everything.
After trying that and seeing how it works, make your object and keep in mind how bid your class is because it will take longer to save if bigger. If it is simple, it should save faster.
To save EWR, you need a Thread.Sleep() for some time to make the system idle. Typically in an application, you do not need to sleep and EWR will be written in the background.
Do not use Watchdog to test, you can use soft reboot. Something like powerstate.Reboot(…)