Defaultsettings = Control doesnt show

Jun 18, 2012 at 4:32 PM

Hey.

Started using this control as it's exactly what I'm looking for but I cannot get it to display ANYthing.

I do not have any settingsurl on the web, so I'm only using this:

DefaultSettingsFileUri="/APPNAME;component/defaultAdSettings.xml"

But this doesn't fetch anything, and the control remains collapsed.

Same thing happens if I try it with the sample project. Deleting this:

SettingsUrl="http://xna-uk.net/adrotator/SLdefaultAdSettingsV2.xml"

Causes the ad control to never show anything, even though the sample project is supposed to use the defaultsettings.xaml file (which I havent changed at all). 

What the h*** am I doing wrong ? :(

Coordinator
Jun 18, 2012 at 4:57 PM

I'll look into this tonight to see if I can reproduce it.

If you remove SettingsUrl the ad control should just fall back to DefaultSettingsFileUri. My feeling is that the URI you provide isn't getting resolved correctly - either because the xml is not a resource or because the path is not correct. Looking at the output window might also have some useful error / warning messages.

Jun 18, 2012 at 6:35 PM

Yeah thats what I thought it would do (fall back to defaultsettings.xaml).

The file is set as resource, path SHOULD be correct... and output window doesn't show anything.

Hoping you or someone can reproduce / tell me the fix :)

Jun 18, 2012 at 9:25 PM

Just tried putting the xml file from my VS2010 project on my NAS, and using the file in settingsurl = works....

I get an adexception though because there was no ads to show.

Jun 19, 2012 at 3:44 PM
Edited Jul 16, 2013 at 4:16 PM
Hi all,

When i debug source code, I figured out how to fix at http://stackoverflow.com/questions/3996768/application-getresourcestream-throws-ioexception

I changed "DefaultSettingsFileUri" like this:

public Uri DefaultSettingsFileUri
{
        get { return (Uri)GetValue(DefaultSettingsFileUriProperty); }
        set { SetValue(DefaultSettingsFileUriProperty, new Uri(value.OriginalString,UriKind.Relative)); }
}

Source Code: http://www.mediafire.com/?fl136fonhqecjfk

DLL : http://www.mediafire.com/?pus23s8n7j1vxbb

Note: you must set your file config is resource( right click to your file, choice property, build action set resource).

If you have problems please send email for me (tano8753@gmail.com).
Jun 28, 2012 at 4:19 PM
Edited Jun 28, 2012 at 4:20 PM

This can be worked around without changing the code, but there is a bug in the latest version of the DLL, so if you want to change the control project and re-compile you can. Problem line is (I think) 762 in the AdRotatorControl.xaml.cs file which reads:

_settings = LoadAdSettings(); // GetDefaultSettings();

If you put back in the GetDefaultSettings instead of LoadAdSettings, I think it'll work.

If you don't want to bother with that you can still get around it, just set the SettingsUrl property to a valid URL that doesn't point to anything, e.g:

 

SettingsUrl="http://localhost"

 

and as long as your DefaultSettingsFileUri property is valid, it should work.

I have tested the work around and it's good for me, but although I think the fix for the AdRotator project is right, I havn't tested it.

Coordinator
Jun 28, 2012 at 5:09 PM

Just to validate, as the comment above will kind of work arround the problem but doesn't fix it.

 

The resolution to this has to do with how we handle the setting of the DefaultSettingsFileUri property from Silverlight.  The issue is that it only currently upadates if the control has been initialised which previously only happened if you had set a SettingsURI.

 

The fix that will be pushed in once we've completed testing and other improvements is as follows, you simply need to replace the following "OnDefaultSettingsFileUriChanged" method with the above code.  This ensures that if you only use the local settings file it will apply correctly. 

 

private void OnDefaultSettingsFileUriChanged(DependencyPropertyChangedEventArgs e)
{
	if (!_initilised && string.IsNullOrEmpty(SettingsUrl))
	{
		_initilised = true;
		 _settings = LoadAdSettings();
		 Invalidate();
	}
}

If you use the previous example then if you did ad a remote configuration file it would never update correctly.  

 

Jun 29, 2012 at 11:49 AM

Yeah, sorry, should have been more explicit there, I wasn't trying to suggest an "official" fix to the control, just one to workaround the specific problem of the control not loading the backup config file if you don't specify an online one.

Not very altuistic of me I know, but I'd been tearing my hair out over it and figured it might save someone else a couple of hours head-scratching :)

Coordinator
Jun 29, 2012 at 1:03 PM

No worries Ruairi, glad your getting involved.

Feel free to keep offering advise where you can, we'll take whatever help we can.

Thanks

Simon