Posts Tagged ‘C#’

STSADM From Your Visual Studio

This Trick Allan showed me…

You can add a menu tool to your visual studio to add/upgrade/delete your WSP solution If it located in the same folder for your VS Project

Open your Visual Studio Select Tools > External Tools then Click ADD

Tool 1 :"Add WSP" this tool Adds Your WSP solution to the Share Point Solutions List … How Ever It Adds it Without Deployment So you need to Open Administration site for share point and open Central Administration > Operations > Solution Management to deploy the project after using this tool

back to what we were saying

image

Too1:

Write the following

Title : Add WSP

Command : system Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE

Arguments : -o addsolution -filename $(TargetName).wsp

Initial Directory : $(ProjectDir)

Check Use Out Put window Option

Tool2: UpGrade WSP (Only Works When Your Solution is Deployed Already on share Point Used Up Grade the WSP Solution)

Title : UpGrade WSP

Command :system Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE

Arguments : -o upgradesolution -filename $(TargetName).wsp -name $(TargetName).wsp  -immediate -allowgacdeployment

Initial Directory :  $(ProjectDir)

Check Use Out Put window

Tool3:(Removes the WSP Solution From the share point Solutions how ever the solution must be retracted before using this tool, to retract your solution open Administration site for share point and open Central Administration > Operations > Solution Management )

Title : Remove WSP

Command : system Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE

Arguments : -o deletesolution -name $(TargetName).wsp

Initial Directory : $(ProjectDir)

Check Use Out Put window

To Make any of These Tools Work You must First Select the Project in the Solution Explorer window In the VS before selecting the tool from the tools menu … Also the WSP solution must be in your project Directory.

To Generate the WSP solution from Your VS you can see the tool I mentioned in my Previous Post

I made tool for the WSPBuilder From my Previous Post to generate the Wsp in the project folder

Tool4:(generate Wsp file from VS project in the project`s folder)

Title : WSP Build

Command : WSPBuilder Tool Path\WSPBuilder.exe

Arguments :

Initial Directory : $(ProjectDir)

Check Use Out Put window

 

So you can develop your project use tool4 to generate the wsp solution use too1 to add it to the share point solutions ,deploy it from the administration site and if you made some modifications to the project you simply rebuild it and then use tool 4 and finally use tool 2.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 

See Dlls Implementation

If you want to See some of .Net dlls Implementation there is an Cool tool that shows you all the .Net Class code and Provide you with some extra details like the dlss version,Culture and the token key

More over you can browse to any local dll  the reflector will do the rest of the work

this Program name is Reflector.exe

(Available for free via – this link)

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 

Pocket PC Emulator and Web Services

If you are trying to make a Pocket Pc application that connects to Web services
You will Probably Have Faced A lot of problems connecting to your WS
that is because you need to do the following
-you have to install Active sync 4.1 or later versions to make your emulator connected to the net
-you need to assign your pc static IP and you must be connected to real network
-When you add a Web Reference of your Web Service Instead of using “Local” in the WS Url write the static IP you made.

I don’t know if there is any better way to make it work … but is the only way made the emulator connect to WS with me…

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 

XslCompiledTransform and xsl Scripts

If you are Upgrading Project from .Net 1 to .Net 2 you Will now know that XslTransform is now deprecated. and it is better to use System.Xml.Xsl.XslCompiledTransform
For more info :  see this .

So instead of

 

XslTransform.Load(XslPath);

You will need to write this code instead

XmlUrlResolver XResolver = new XmlUrlResolver();

XResolver.Credentials = 

System.Net.CredentialCache.DefaultCredentials;

XslTransform.Load(fullPath, 

new XsltSettings(true, true), XResolver);

 

How Ever XslComiledTransform still have some security matters.

I was using Aspose.Pdf dlls www.aspose.com To Generate Pdf file from and Xml Data using and Xsl Sheet that had a kind of C# script to get the date time to show it in the footer of the report

but those scripts generated temp dlls and XslCompiledTransform created them in the Temp Folder of the windows and that generated security Permissions error

So after long search i removed the scripts in the Xsl Sheet and passed the calculated Values as Xsl Parameters

To Pass Xsl Paramter in the Xsl File :

xsl:param name="date" /

To Dispaly Xsl Paramter :

xsl:value-of select="$date" /

To Transform the File Using C#:

 

XsltArgumentList reportArgs = new 

XsltArgumentList();

reportArgs.AddParam("date", string.Empty, 

DateTime.Now.ToString());

MemoryStream reportMS = new 

MemoryStream();

xslCompiledTransform.Transform(Xmldata, reportArgs, 

reportMS);

For more information

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 

c:\Windows\Temp And temp dlls Generated

Without a lot of big introductions….

The Problem:
Some of the .Net Classes when used generate a temp dlls and then use it to call certain code or even make some operations in the local server
However those temp dlls are saved in the temp file of the application which usually set by default to c:\Windows\Temp which is a very secure file and needs permissions to read or to write from this file…
And as used Microsoft didn’t do all the work….in a way or anther the permission to .Net classes is generating the dlls is managed in windows Xp but it is note managed in windows 2003
So if you are developing your web application on xp and deploying to 2003 server strange errors will appear to you because of this problem

N.B. Sometimes Crystal reports generate the same error by saving temp reports in the windows temp file.

Solution:

Attempt 1:
If Your Applications Is Using the Asp.Net Authentications…. You can simply give the permissions to the ASP User on the Windows Temp Folder and You are done however this Solution is not safe because you open the server temp file to anyone to write in …!!
Any way attempt 2 might help you with that

Attempt 2
By more search I found out that you can change the temp folder for your web application and prevent it from using the default file (c:\Windows\Temp)
Using this code

Environment.SetEnvironmentVariable("TEMP", "c:\\Filename"); Environment.SetEnvironmentVariable("TMP", "c:\\Filename");
And adding this tag in the web config

compilation tempDirectory="c:\FileName"

As you can notice you have to change both the variables TEMP and TMP as Microsoft uses to Variables for the Temp Files……….

Attempt 3:

If You know the part of the code that generates the temp dlls you can use the impersonate class to change the current user to a anther user from the servers user that have permissions to the temp folder of the application and after performing the target code you can return back to the original user
You will find this link very useful if you are attempting to do this solution

Attempt 4:
the poorest solution to make this problem work out is to add this tag in the config file
trust level="full" originUrl=""
but that will make the pc opened to any user to do whatever he wants… so it is not a solution actually :)

Attempt 5 :
This is the attempt where I succeeded to make the problem work out; in my case I knew exactly the part that generated the temp Dlls
I was using XslCompiledTransform to Transform an Xsl file that contains Scripts, Those scripts was the reason for generating the temp dlls, so I just removed the scripts and passed the values calculated by them as xsl param, for more details read my next post."XslCompiledTransform and xsl Scripts"

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
 

 

View Abdel-Rahman Awad's profile on LinkedIn

Archives

 

Rss Feed Tweeter button Facebook button Linkedin button Delicious button Digg button