Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Resourcedictionary in dll; pack uri no longer working

 
 
Old 08-19-2007   #1 (permalink)
Ralf Ziller


 
 

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


 
 

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


 
 

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


 
 

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


 
 

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


 
 

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


 
 

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


 
 

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
 

Thread Tools


Similar Threads
Thread Forum
Service Pack 1 - how much longer? Vista General
USB no longer working Vista hardware & devices


Vista Forums 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 Ltd

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