Wednesday, April 28, 2010

XBAP - SiteOfOrigin Files

 

I used this little snippet after a couple of hours hunting MSDN forums

StreamResourceInfo f = Application.GetRemoteStream(new Uri("pack://siteoforigin:,,,/"+fileSolutionPath));

//f.Stream //to your IO with this

Note: siteoforigin files are downloaded from the host on demand, so should be downloaded as needed.

Cool little beasty

http://msdn.microsoft.com/en-us/library/aa970494.aspx#Site_of_Origin_Files

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9df060ca-019e-4443-8167-ccf511a73f84

I actually used this to copy some configuration files, DICOM Server Association files, to my Full Trusted XMAP home. I had made the Full Trust XMAP home (Environment.CurrentDirectory) a Temp folder i.e. System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MyAppName") and needed to get the association list for a Storage SCP.

Thus

f.Stream.CopyTo((File.OpenWrite(Path.Combine(Environment.CurrentDirectory, fileSolutionPath))));

Tuesday, April 27, 2010

XBAP – Full Trust on the net

http://weblogs.asp.net/scottgu/archive/2009/10/26/wpf-4-vs-2010-and-net-4-0-series.aspx

Full Trust XBAP Deployment

Starting in WPF 4, the ClickOnce elevation prompt is also enabled for XAML Browser Applications (XBAPs) in Intranet and Trusted Zones, making it easier to deploy full-trust XBAPs. For XBAPs that require security permissions greater than the minimum code access security (CAS) permission grantset of the Intranet and Trusted Zones, the user will be able to click 'Run' on the ClickOnce elevation prompt when they navigate to the XBAP to allow the XBAP to run with the requested permissions.

While developing DVD Burner Application, I wondered how many people are going to use the application then I came across XBAP and Full Trust. Although not a standard application of a Web App, it seems that XBAP is allowing me to get Full Trust via the internet. Very promising…

The key testability point for me was the “Intranet” AND “Trusted Zones”.

I could deploy the application on my laptop with IIS7.0 over the internet, and test it using my remote IP. This allowed me to test without being on a domain.

The only thing to do was to add my Remote IP to the “Trusted Zones” in IE, as long as your app is signed.

Very Cool Stuff

VS2010 – cmd prompt .NET v3.5

I was trying to sign an assembly that I did have direct access to the code, in a Domain constrained SVN repo, and came across this:
http://buffered.io/2008/07/09/net-fu-signing-an-unsigned-assembly-without-delay-signing/
Well I did it all and found that VS2010 has ilasm 4.0, thus making an assembly that is .NET 4.0 targeted. Now I cant reference the assembly from a .NET 3.5 project.
I decided to create a shortcut that executed the older .NET tools i.e. “Visual Studio Command Prompt” 3.5
The two file, vcvarsall.bat and vcvars32.bat, control the way VS cmd prompt sets up the environment and should be copied as follows:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.35.bat
C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.35.bat

vcvars32.35.bat


@if not "%WindowsSdkDir%" == "" (
    @set "PATH=%WindowsSdkDir%bin;%WindowsSdkDir%bin\NETFX 4.0 Tools;%PATH%"
    @set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
    @set "LIB=%WindowsSdkDir%lib;%LIB%"
)


@if exist "%VCINSTALLDIR%VCPackages" set PATH=%VCINSTALLDIR%VCPackages;%PATH% @set PATH=%FrameworkDir%%FrameworkVersion%;%PATH% @set PATH=%FrameworkDir%v2.0.50727;%PATH%
@set PATH=%FrameworkDir%%Framework35Version%;%PATH%

@set PATH=%VSINSTALLDIR%Common7\Tools;%PATH%



vcvars32.35.bat is modified to place the 3.5 tools first before 4.0.
Note: ilasm before v4.0 is v2.0.50727 so this is placed between the 3.5 and 4.0 versions
         i.e. 3.5 then 2.0 then 4.0

vcvarsall.35.bat


:x86
if not exist "%~dp0bin\vcvars32.35.bat" goto missing
call "%~dp0bin\vcvars32.35.bat"
goto :eof


vcvarsall.35.bat is only modified to call vcvars32.35.bat NOT the original vcvars32.bat(4.0)
Now just copy the “Visual Studio Command Prompt (2010)” shortcut and replace “vcvarsall.bat”  parameter with “vcvarsall.35.bat”
now .NET 2.0 ilasm runs from this new shortcut.