Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Resourcedictionary in dll; pack uri no longer working

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 08-19-2007   #1 (permalink)
Ralf Ziller
Guest


 

Resourcedictionary in dll; pack uri no longer working

I have a dll that does some geometric conversions. For this I need some
geometry templates that I put in a resourcedictionary.
Whatever I did I could not get this resourcedictionary to load. Then I added
the dictionary as content I could load it. I thought I could sort it out
later and went on with my work.
Now I got back to testing the resourcedictionary but now I cannot load it as
content file. When I create the pack-uri I get an exception: "Invalid Uri.
Because of a double point a connection was expected but the connection could
not be analysed." (Something like that, I get the german version of this
error).
My Uri looks like this:
pack://application:,,,/path/dictionary.xaml
What could be wrong? I do not know of any relevant changes. Anyhow my
changes in the app shouldn't affect the Uri-parser...

My System SpecsSystem Spec
Old 08-19-2007   #2 (permalink)
Ralf Ziller
Guest


 

RE: Resourcedictionary in dll; pack uri no longer working

I just tried using an absolute Uri for loading the resourcedictionary but got
an InvalidOperationException ("Error at LoadFrom with the Uri '...' ").
I tried a reinstall of the Visual Studio CTP Extensions, reinstall of
..Net3.0 is not possible as this is Vista.
My System SpecsSystem Spec
Old 08-19-2007   #3 (permalink)
Laurent Bugnion, MVP
Guest


 

Re: Resourcedictionary in dll; pack uri no longer working

Hi,

Ralf Ziller wrote:
> I have a dll that does some geometric conversions. For this I need some
> geometry templates that I put in a resourcedictionary.
> Whatever I did I could not get this resourcedictionary to load. Then I added
> the dictionary as content I could load it. I thought I could sort it out
> later and went on with my work.
> Now I got back to testing the resourcedictionary but now I cannot load it as
> content file. When I create the pack-uri I get an exception: "Invalid Uri.
> Because of a double point a connection was expected but the connection could
> not be analysed." (Something like that, I get the german version of this
> error).
> My Uri looks like this:
> pack://application:,,,/path/dictionary.xaml
> What could be wrong? I do not know of any relevant changes. Anyhow my
> changes in the app shouldn't affect the Uri-parser...


From the title of your post it sounds as if the dictionary.xaml is
located in an external DLL. In this case, the pack URI should be:

pack://application:,,,/externalDllName;component/path/dictionary.xaml

For more info about pack URIs, check this page:

http://msdn2.microsoft.com/en-us/library/aa970069.aspx

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 08-20-2007   #4 (permalink)
Ralf Ziller
Guest


 

Re: Resourcedictionary in dll; pack uri no longer working


"Laurent Bugnion, MVP" wrote:
>
> From the title of your post it sounds as if the dictionary.xaml is
> located in an external DLL.


No, the project is a dll which does the conversions and should be used from
applications and perhaps websites. The dictionary should be inside this dll
and only be used inside this dll. Sorry for this misleading formulation.

Ralf
My System SpecsSystem Spec
Old 08-20-2007   #5 (permalink)
Ralf Ziller
Guest


 

Re: Resourcedictionary in dll; pack uri no longer working

I have a correct translation of the error now:
"Invalid URI: A port was expected because of there is a colon (':') present
but the port could not be parsed."

If I use a relative URI as stated in
http://msdn2.microsoft.com/en-us/library/aa970069.aspx
I get another error:
"Unknown URI prefix"

My System SpecsSystem Spec
Old 08-20-2007   #6 (permalink)
Laurent Bugnion, MVP
Guest


 

Re: Resourcedictionary in dll; pack uri no longer working

Hi,

Ralf Ziller wrote:
> I have a correct translation of the error now:
> "Invalid URI: A port was expected because of there is a colon (':') present
> but the port could not be parsed."
>
> If I use a relative URI as stated in
> http://msdn2.microsoft.com/en-us/library/aa970069.aspx
> I get another error:
> "Unknown URI prefix"


I made a quick test. Here is the structure in my Solution:

Solution
- myFolder1
- myFolder2
- Dictionary1.xaml
- Window1.xaml

If I want to include Dictionary1.xaml in my Window1's resources, I use
either the short form:

<Window.Resources>
<ResourceDictionary
Source="myFolder1/myFolder2/Dictionary1.xaml"/>
</Window.Resources>

or the long (though the long form has no advantage for the "application"
authority:

<Window.Resources>
<ResourceDictionary

Source="pack://application:,,,/myFolder1/myFolder2/Dictionary1.xaml"/>
</Window.Resources>

(sorry for the wrapping)

If you tried this, and it didn't work, try to make the smallest possible
repro of this problem, and zip it and email it to me if you want, I'll
look at it.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 08-21-2007   #7 (permalink)
Ralf Ziller
Guest


 

Re: Resourcedictionary in dll; pack uri no longer working

Hello,

this works for me, too.
But I needed to access the Resourcedictionary from code:
ResourceDictionary d = new ResourceDictionary();
d.Source=new Uri("Dictionary.xaml");
I found this in several examples but it does not work.
Now I take a Custom UserControl which holds the resources. That works perfect.

Thanks for your answers
Ralf

"Laurent Bugnion, MVP" wrote:
>
> <Window.Resources>
> <ResourceDictionary
> Source="myFolder1/myFolder2/Dictionary1.xaml"/>
> </Window.Resources>


My System SpecsSystem Spec
Old 08-25-2008   #8 (permalink)
Pavol Bosik
Guest


 

Programatically merging a ResourceDictionary.

I had the same problem.
This fixed it:

ResourceDictionary d = new ResourceDictionary();
d.Source=new Uri("<AssemblyName>;component/Dictionary.xaml", UriKind.Relative);

(replace <AssemblyName> with the real name of your assembly)

BTW, subfolders are possible, too.

For example, if the assembly were named 'Common' and the folder structure in Solution Explorer were
Common
- BaseClasses
- Gui
- Dictionary.xaml
, you would have initialized the source like this:

d.Source = new Uri("Common;component/BaseClasses/Gui/Dictionary.xaml", UriKind.Relative);

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Service Pack 1 - how much longer? Vista General 29 06-29-2008 12:18 PM
USB no longer working mrinventions General Discussion 0 03-01-2008 11:01 AM
wmp and wmc no longer working snewton62 Vista music pictures video 4 05-04-2007 03:28 AM
USB no longer working darthsabre Vista hardware & devices 1 03-09-2007 07:57 PM
ResourceDictionary bug Guillaume Avalon 1 03-22-2006 09:49 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51