Skip to main content

Microsoft Silverlight

Answered Question Manually embeding an XAML to a DLLRSS Feed

(0)

di6k
di6k

Member

Member

42 points

13 Posts

Manually embeding an XAML to a DLL

I'm not the type of guy who likes to work with VS, I just work with a regular text editor, therefore most of my work is done manually, like compiling, debuging etc... I've been trying to embed a XAML file to a DLL assembly as a resource while compiling. I've also loaded the XAML inside the application but I get no result at all.

 

Does anybody knows how to embed MANUALLY the XAML into the DLL without working with VS?

 

Thanks in advance,

David E. Salazar
david@salazar.ms

ssawchenko
ssawchenko

Member

Member

342 points

177 Posts

Re: Manually embeding an XAML to a DLL

Not sure about embedding manually, but, when you tried to load the xaml as a resource while compiling [I imagine in VS] did you open up the properties of the xml file and select "embedded resource" as the build action?

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Manually embeding an XAML to a DLL

Just curious. Can you explain why you don't want to make use of the Visual Studio environment? Everybody who I've spoken to tell me Visual Studio is the best IDE they ever used.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

ssawchenko
ssawchenko

Member

Member

342 points

177 Posts

Re: Manually embeding an XAML to a DLL

ssawchenko:

Not sure about embedding manually, but, when you tried to load the xaml as a resource while compiling [I imagine in VS] did you open up the properties of the xml file and select "embedded resource" as the build action?

Sorry, I think I misread your first post [I thought you used VS at some point].  I'm afraid I have no idea how to do this manually, although perhaps there is an "embedded resource" equivalent flag.

In my VS project file the tagging for it looks like:

 <ItemGroup>
    <EmbeddedResource Include="FakeData.txt" />
  </ItemGroup>

 

The intellisense alone is enough to make me use an IDE like VS... I think I would pull out my hair without it. 

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Answered Question

Re: Manually embeding an XAML to a DLL

I am under the impression that you cannot do that, since the Xaml is compiled into the DLL...  Not 100% sure though since there is a distinction between "Resource" and "Embedded Resource".

On the other hand, if you just want to be able to reference the Xaml from within the application, and want to do so without VS, you can do it at the XAP level.  You can use 7zip (free) to add the Xaml file into XAP (which is really a zip file).  You don't even need to change its extension to do that.  I have a script that put a timestamp file into the XAP...  Actually very straightforward...

7zip.exe -tzip a App.Xap Timestamp.txt

This is how you get back the file from the XAP (you must know the name of the file, say Timestamp.txt in the following example):

            string url = "Timestamp.txt";
            System.Windows.Resources.StreamResourceInfo sri = Application.GetResourceStream(
                new Uri(url, UriKind.Relative));
            if (sri == null)
                throw new Exception();
            return sri.Stream;
 

SharpGIS has a small utility to get all files in the XAP if you need to load all Xamls.

di6k
di6k

Member

Member

42 points

13 Posts

Re: Manually embeding an XAML to a DLL

The deal if the following, I can't afford Visual Studio, and the Express version isn't so good if I aim Silverlight. Eclipse, just sucks, I've never been in the open source world. I do have a Visual Studio with a student or somewhat license which let me use VS a study and investigation tool, not for production, therefore my comercial projects have to be done some other way.

 I use NoteTabPro as a text editor, neat, nice, with tabs, some text formating, but just that. Plain simple text editor. I compile manually via a batch file, in the comiling sequence I have added the /resorce:app.xaml sentence. Inside the source code I've also added the Application.LoadComponent(this, new Uri("/app;component/app.xaml", UriKind.Relative)); to load the visual layout of the application, but I only get to render what I had directly from the source code. What ever I add through the XAML code is lost in a parallel dimension. So... I don't know if the XAML file is being embeded correctly into the application DLL, at least from that point I can load the XAML into the application. In an example build in VS I have seen in the temporary resource file that both XAML files App.xaml and MainPage.xaml are both embeded as one file, so far, easy to understand, in the compiling sequence that .resource file is added just as a resource of the application. In side the App.g.cs and MainPage.g.cs file I see both sentences to add the XAML code to the controls, the Application and the UserControl.

 As far as I've tried, what I'm doing is the same thing, but with no result at all, and since I can't deal with license problems, I must develop my software with my ancient NoteTabPro and manual compiling through a batch file.

 Hope anyone can tell me how to add, efficiently the XAML file into the DLL.

 

Thanks everyone

David E. Salazar
david@salazar.ms

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Manually embeding an XAML to a DLL

Not sure if you read my reply but take a look.  May work for you.

I currently use both VS2008 Professional and Visual Web Designer Express 2008, almost interchangeably.  I concluded that I could have just used VWD Express and be able to do most everything I need to do with Silverlight.  You may want to give that a try.  To me, having a good IDE is a huge part of the development process...  Some would even say that Silverlight is better than other RIAs for this very reason.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities