<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Vijay - Blog Space</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/vijay/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/vijay/feed.xml</link>
    <description />
    <lastBuildDate>Sat, 11 Apr 2015 01:10:34 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SharePoint 2010 - System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/sharepoint-2010-system-unauthorizedaccessexception-access-is-denied-exception-from-hresult-0x80070005-e_accessdenied</link>
      <pubDate>Fri, 22 Jul 2011 11:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2011/07/22/sharepoint-2010-system-unauthorizedaccessexception-access-is-denied-exception-from-hresult-0x80070005-e_accessdenied/</guid>
      <description><![CDATA[&nbsp;
I am sure many would have experienced this issue while connecting to a SharePoint site from...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>I am sure many would have experienced this issue while connecting to a SharePoint site from an Asp.Net application. You normally would get these errors:</p>
<p>1<b>. System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))</b> at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex) at Microsoft.SharePoint.Library.SPRequest.GetListsWithCallback(String bstrUrl, Guid foreignWebId, String bstrListInternalName, Int32 dwBaseType, Int32 dwBaseTypeAlt, Int32 dwServerTemplate, UInt32 dwGetListFlags, UInt32 dwListFilterFlags, Boolean bPrefetchMetaData, Boolean bSecurityTrimmed, Boolean bGetSecurityData, Boolean bPrefetchRelatedFields, ISP2DSafeArrayWriter p2DWriter, Int32&amp; plRecycleBinCount) at Microsoft.SharePoint.SPListCollection.EnsureListsData(Guid webId, String strListName) at Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException) at _Default.btnClick_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Contoso\Default.aspx.cs:line 35</p>
<p>2. <b>The Web application at https://localhost/sites/SPApplication101/ could not be found.</b> Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.</p>
<p>However, if you try to access the same SharePoint application from a console application or windows application (provided the target framework is Any CPU or x64; because, SharePoint 2010 <b>runs in x64 mode only</b>).</p>
<p>Now, there could be following reasons behind these errors.</p>
<p>1. Your ASP.NET application may be targeting to x86 framework and not Any CPU or x64.</p>
<p>2. The user account which is running the ASP.NET application may not have access to SharePoint application.</p>
<p>3. The application pool identify of the application pool of the ASP.NET application doesn&rsquo;t have the access to SharePoint.</p>
<p>The solution to the above:</p>
<p>1. Make sure your ASP.NET application is targeting x64/Any CPU.</p>
<p>2. Run your code inside the block &ldquo;<b>SPSecurity.RunWithElevatedPrivileges</b>&rdquo;.</p>
<p>3. Make sure the application identity of the app pool of ASP.NET application has the access to the SharePoint application which your accessing. Alternatively, you can use the SharePoint&rsquo;s application with your ASP.NET application.</p>
<blockquote>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="color: #0000ff; font-size: 9.5pt;" color="#0000ff">try</span></span></span><span></span></p>
</blockquote>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style="background-color: #ffff00;"><span style="font-size: 9.5pt;"><span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%; mso-highlight: yellow;"><span style="color: #2b91af;" color="#2b91af">SPSecurity</span></span></span><span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%; mso-highlight: yellow;"><span style="font-size: 9.5pt;">.RunWithElevatedPrivileges(<span><span style="color: #0000ff;" color="#0000ff">delegate</span></span>()</span></span></span></b></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #2b91af;" color="#2b91af">SPSite</span></span> mySite = <span><span style="color: #0000ff;" color="#0000ff">new</span></span> <span><span style="color: #2b91af;" color="#2b91af">SPSite</span></span>(<span><span style="color: #a31515;" color="#a31515">"</span><a href="https://localhost/sites/SPApplication101/"><span style="color: #0000ff;" color="#0000ff">https://localhost/sites/SPApplication101/</span></a><span style="color: #a31515;" color="#a31515">"</span></span>);</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">using</span></span> (<span><span style="color: #2b91af;" color="#2b91af">SPWeb</span></span> myWeb = mySite.OpenWeb())</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">int</span></span> i = 1;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">string</span></span> strFolder = <span><span style="color: #a31515;" color="#a31515">"Folder"</span></span>;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mySite.AllowUnsafeUpdates = <span><span style="color: #0000ff;" color="#0000ff">true</span></span>;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myWeb.AllowUnsafeUpdates = <span><span style="color: #0000ff;" color="#0000ff">true</span></span>;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #2b91af;" color="#2b91af">SPDocumentLibrary</span></span> docLibrary = (<span><span style="color: #2b91af;" color="#2b91af">SPDocumentLibrary</span></span>)myWeb.Lists[<span><span style="color: #a31515;" color="#a31515">"Word Docs"</span></span>];</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #2b91af;" color="#2b91af">SPFolderCollection</span></span> myFolders = myWeb.Folders;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">if</span></span> (docLibrary != <span><span style="color: #0000ff;" color="#0000ff">null</span></span>)</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">while</span></span> (i &lt;= 10)</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFolder = strFolder + <span><span style="color: #a31515;" color="#a31515">" "</span></span> + i.ToString();</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">if</span></span> (!myWeb.GetFolder(strFolder).Exists)</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myFolders.Add(docLibrary.ParentWebUrl + <span><span style="color: #a31515;" color="#a31515">"/Word%20Docs/"</span></span> + strFolder + <span><span style="color: #a31515;" color="#a31515">"/"</span></span>);</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; docLibrary.Update();</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strFolder = <span><span style="color: #a31515;" color="#a31515">"Folder"</span></span>;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span><span style="color: #0000ff;" color="#0000ff">catch</span></span> (<span><span style="color: #2b91af;" color="#2b91af">Exception</span></span> ex)</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Write(ex.ToString());</span></span></span></p>
<p style="margin: 0in 0in 0pt;" class="MsoNormal"><span><span style="font-family: Tahoma;" face="Tahoma"><span style="font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></p>
<p>-------------</p>
<p>Hope this helps many! <img style="border-style: none;" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/67/04/metablogapi/1856.wlEmoticon-smile_2F863090.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-67-04-metablogapi/1856.wlEmoticon_2D00_smile_5F00_2F863090.png" /></p>]]></content:encoded>
    </item>
    <item>
      <title>"Set-AuthenticodeSignature" returns Unknown Error while registering the script with a certificate</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/set-authenticodesignature-returns-unknown-error-while-registering-the-script-with-a-certificate</link>
      <pubDate>Tue, 13 Jul 2010 09:24:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2010/07/13/set-authenticodesignature-returns-unknown-error-while-registering-the-script-with-a-certificate/</guid>
      <description><![CDATA[Recently I have been working on a PowerShell Project where I needed to sign the scripts with the...]]></description>
      <content:encoded><![CDATA[<p>Recently I have been working on a PowerShell Project where I needed to sign the scripts with the code signing certificates (the ExecutionPolicy was set to "AllSigned"). </p>
<p>I did this before many times without a single problem/error. But this time when I tried to sign the scripts with the certificates I got the &ldquo;Unknown&rdquo; error message returned on the PowerShell console. </p>
<p>It was totally bewildering experience&hellip;I didn&rsquo;t know what to do. Then I realize the only difference this time is that I was using PowerShell ISE to write the scripts (whereas earlier I have been using Notepad to create the scripts). </p>
<p>Now the question comes what the problem using ISE then? </p>
<p>Answer is PowerShell ISE by default saves the scripts file (ps1) in &ldquo;Unicode big endian&rdquo; and that doesn&rsquo;t work while signing the scripts. </p>
<p>Workaround is you can use the Notepad to change the encoding to UTF-8 and then sign the script. Everything will be fine now. </p>
<p>Other workaround is to save the file in ISE by changing the ISE&rsquo;s current encoding: $psISE.CurrentFile.Save([Text.Encoding]::UTF8) </p>
<p>Hope this helps many! </p>
<p>Vijay</p>]]></content:encoded>
    </item>
    <item>
      <title>What is “Name Decoration” or “Name Mangling”?</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/what-is-name-decoration-or-name-mangling</link>
      <pubDate>Fri, 02 Oct 2009 13:29:25 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/10/02/what-is-name-decoration-or-name-mangling/</guid>
      <description><![CDATA[Some of my partners, I have worked, have experienced the errors, while calling a native DLL (written...]]></description>
      <content:encoded><![CDATA[<p>Some of my partners, I have worked, have experienced the errors, while calling a native DLL (written in C++) from a managed .NET application using PInvoke; and that inspired me to write this blog. </p>  <p>The one of the most common errors is &quot;System.DllNotFoundException&quot; occurred in the &lt;application&gt;. Unable to load the dll and the specified module could not be found. (Exception from HRESULTL 0x8007007E). </p>  <p>One of the reasons behind this could be the name you are providing to the &quot;EntryPoint&quot; property of &quot;DllImport&quot; attribute is not matching with the function you are exporting from the native component. </p>  <p>But wait, you verified and checked, the names (lets assume &quot;fnAddNumbers&quot;) in native DLL and the .net app are absolutely same. Then, why this error? </p>  <p>Actually, when you create a C++ native DLL, then compiler changes the names of the functions,by encoding the name of the symbols to include the type information. This is known as &quot;Name Decoration&quot; or &quot;Name Mangling&quot; which insures the type-safe checking. Also, this also make the functions unique when the export symbols are generated, in case of &quot;function overloading&quot;. </p>  <p>You can use &quot;dumpbin.exe&quot; tool&#160; (/exports switch) to check what are the exported names. </p>  <p>This will something like this for the functions: </p>  <p>CPP2_API int fnAddNumbers(int x, int y)    <br />{     <br />&#160;&#160;&#160; return x+y;     <br />} </p>  <p>CPP2_API int fnAddNumbers(int x, int y, int z)    <br />{     <br />&#160;&#160;&#160; return x+y+z;     <br />} </p>  <p>================================================================== </p>  <p>&#160;&#160;&#160; ordinal hint RVA&#160;&#160;&#160;&#160;&#160; name </p>  <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1&#160;&#160;&#160; 0 000110AA ??0CCPP2@@QAE@XZ = @ILT+165(??0CCPP2@@QAE@XZ)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 2&#160;&#160;&#160; 1 0001118B ??4CCPP2@@QAEAAV0@ABV0@@Z = @ILT+390(??4CCPP2@@QAEAAV0@ABV0@@Z)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3&#160;&#160;&#160; 2 000110D7 <strong>?fnAddNumbers@@YAHHH@Z</strong> = @ILT+210(?fnAddNumbers@@YAHHH@Z) -&gt; This function takes two &quot;int&quot; parameters.     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 4&#160;&#160;&#160; 3 00011186 <strong>?fnAddNumbers@@YAHHHH@Z</strong> = @ILT+385(?fnAddNumbers@@YAHHHH@Z) - -&gt; This function takes three &quot;int&quot; parameters.     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 5&#160;&#160;&#160; 4 00011087 ?fnCPP2@@YAHXZ = @ILT+130(?fnCPP2@@YAHXZ)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 6&#160;&#160;&#160; 5 00017138 ?nCPP2@@3HA = ?nCPP2@@3HA (int nCPP2) </p>  <p>================================================================== </p>  <p>So, in the &quot;EntryPoint&quot; you will need to pass the values as &quot;?fnAddNumbers@@YAHHH@Z&quot; and &quot;?fnAddNumbers@@YAHHHH@Z&quot;: </p>  <p>Example:    <br />[DllImport(@&quot;CPP2.dll&quot;, EntryPoint = &quot;?fnAddNumbers@@YAHHH@Z&quot;)]     <br />public static extern int AddNumbers(int a, int b); </p>  <p>[DllImport(@&quot;CPP2.dll&quot;, EntryPoint = &quot;?fnAddNumbers@@YAHHHH@Z&quot;)]    <br />public static extern int AddNumbers(int a, int b, int c); </p>  <p>However, if you don't want to use the &quot;Name decoration&quot;, then you can use &quot;EXTERN_C&quot;, which will export the function without the name change and then you can use the same function name. Note: This will not work in case of &quot;function overloading&quot;. </p>  <p>Example: </p>  <p>EXTERN_C CPP2_API int fnAddNumbers(int a, int b); </p>  <p>------------------------------------------------------------</p>  <p>Happy Programming!</p>]]></content:encoded>
    </item>
    <item>
      <title>How to list all the sub-sites and the site collections within a SharePoint web application using Windows Powershell</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/how-to-list-all-the-sub-sites-and-the-site-collections-within-a-sharepoint-web-application-using-windows-powershell</link>
      <pubDate>Thu, 01 Oct 2009 17:56:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/10/01/how-to-list-all-the-sub-sites-and-the-site-collections-within-a-sharepoint-web-application-using-windows-powershell/</guid>
      <description><![CDATA[Recently, I worked on a partner's request for enumerating all the sub-sites and the site collection...]]></description>
      <content:encoded><![CDATA[<P>Recently, I worked on a partner's request for enumerating all the sub-sites and the site collection within a SharePoint web application. If you want to do the same thing, may this be useful for you. </P>
<P>Windows Powershell has made it so easy to work/administer with several Microsoft products like, SharePoint, SQL Server, Exchange Server etc., so that almost anyone who has some knowledge of Powershell programming can work with them.</P>
<P>Find out yourself by seeing the code below: </P>
<P>-------------------------------------------------- </P>
<P>[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") &gt; $null </P>
<P>$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local <BR>$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} <BR>$webapps = @() </P>
<P>foreach ($websvc in $websvcs) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Web Applications" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; foreach ($webapp in $websvc.WebApplications) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Webapp Name --&gt;"$webapp.Name <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Site Collections" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; foreach ($site in $webapp.Sites) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Site URL --&gt; --&gt;" $site.URL <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Websites" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; foreach ($web in $site.AllWebs) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Web URL --&gt; --&gt; --&gt;" $web.URL <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Lists" <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; foreach ($list in $web.Lists) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "List Title --&gt; --&gt; --&gt; --&gt;" $list.Title <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; } </P>
<P>&nbsp;&nbsp;&nbsp; foreach ($group in $web.Groups) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "Group Name --&gt; --&gt; --&gt; --&gt;" $group.Name <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" </P>
<P>&nbsp;&nbsp;&nbsp; foreach ($user in $group.Users) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "User Name --&gt; --&gt; --&gt; --&gt;" $user.Name <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-host "" <BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; } </P>
<P>&nbsp;&nbsp;&nbsp; } </P>
<P>&nbsp;&nbsp;&nbsp; } </P>
<P>&nbsp;&nbsp;&nbsp; } <BR>} </P>
<P>-------------------------------------------------- </P>
<P>Happy Programming!</P>]]></content:encoded>
    </item>
    <item>
      <title>How to add the Windows Powershell assembly / namespace in .NET</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/how-to-add-the-windows-powershell-assembly-namespace-in-net</link>
      <pubDate>Thu, 01 Oct 2009 17:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/10/01/how-to-add-the-windows-powershell-assembly-namespace-in-net/</guid>
      <description><![CDATA[I thought it would be easy to create a PSSnapIn using .NET. But that wasn’t the case initially. When...]]></description>
      <content:encoded><![CDATA[<P>I thought it would be easy to create a PSSnapIn using .NET. But that wasn’t the case initially. When I first created a .NET project for creating a PSSnapIn and wanted to work with “<STRONG>Cmdlet</STRONG>” and “<STRONG>PSSnapIn</STRONG>”; I couldn’t add/find the assembly “<STRONG>System.Management.Automation</STRONG>” in my the project. Without this you can’t create your snap-in. The problem is still there and you can’t add this assembly in your project directly by choosing the add reference option. </P>
<P>So, the work around is to open the C# or VB.NET project file in notepad editor and add this line of code under the “&lt;ItemGroup&gt;” section. Save it and then again open in Visual Studio. You should be able to add the namespace “System.Management.Automation” now in your code file and can create the PSSnapIn. </P>
<P>&lt;Reference Include="<STRONG>System.Management.Automation</STRONG>" /&gt; </P>
<P>Now, it was easy to create your customized snapin :) </P>
<P>Happy Programming!</P>]]></content:encoded>
    </item>
    <item>
      <title>How to connect to SQL Server from a Windows Mobile Emulator</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/how-to-connect-to-sql-server-from-a-windows-mobile-emulator</link>
      <pubDate>Thu, 11 Jun 2009 14:19:42 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/06/11/how-to-connect-to-sql-server-from-a-windows-mobile-emulator/</guid>
      <description><![CDATA[Sometime back, I worked with a partner who had been getting SQLExceptions while connecting the SQL...]]></description>
      <content:encoded><![CDATA[<p>Sometime back, I worked with a partner who had been getting SQLExceptions while connecting the SQL Server database from a Windows Mobile Emulators. If you have been getting the same problem/errors, you can try the following steps.</p>  <p>Here are the steps you will have to perform for connecting the SQL Server database:</p>  <p>1. Enable the “Windows Guest” user account (by default this is disabled and you can disable it after the job done).</p>  <p>2. Create a Login Name for the above account in the SQL Server (“&lt;machine-name&gt;/Guest)</p>  <p>3. Give the “<strong>db_datareader</strong>” and “<strong>db_datawriter</strong>”&#160; access to the database, you will access on the server.</p>  <p>4. Cradle the emulator and deploy the application and start accessing the database.</p>  <p>Complete Code:</p>  <p></p>  <pre class="code"><span style="background: silver; color: blue">using </span><span style="background: silver">System;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Linq;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Collections.Generic;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.ComponentModel;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Data;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Drawing;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Text;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Windows.Forms;
</span><span style="background: silver; color: blue">using </span><span style="background: silver">System.Data.SqlClient;

</span><span style="background: silver; color: blue">namespace </span><span style="background: silver">Win65App
{
    </span><span style="background: silver; color: blue">public partial class </span><span style="background: silver; color: #2b91af">Customers </span><span style="background: silver">: </span><span style="background: silver; color: #2b91af">Form
    </span><span style="background: silver">{
        </span><span style="background: silver; color: #2b91af">SqlConnection </span><span style="background: silver">conn = </span><span style="background: silver; color: blue">null</span><span style="background: silver">;
        </span><span style="background: silver; color: #2b91af">SqlDataReader </span><span style="background: silver">dr;
        </span><span style="background: silver; color: #2b91af">SqlCommand </span><span style="background: silver">cmd = </span><span style="background: silver; color: blue">null</span><span style="background: silver">;
        </span><span style="background: silver; color: blue">public </span><span style="background: silver">Customers()
        {
            InitializeComponent();
        }

        </span><span style="background: silver; color: blue">private void </span><span style="background: silver">Customers_Load(</span><span style="background: silver; color: blue">object </span><span style="background: silver">sender, </span><span style="background: silver; color: #2b91af">EventArgs </span><span style="background: silver">e)
        {
            </span><span style="background: silver; color: blue">string </span><span style="background: silver">strConnection = </span><span style="background: silver; color: #a31515">&quot;Data Source=&lt;servername&gt;;&quot; </span><span style="background: silver">+
                </span><span style="background: silver; color: #a31515">&quot;Initial Catalog=Northwind;&quot; </span><span style="background: silver">+
                </span><span style="background: silver; color: #a31515">&quot;Integrated Security=SSPI&quot;</span><span style="background: silver">;
            </span><span style="background: silver; color: blue">try
            </span><span style="background: silver">{
                conn = </span><span style="background: silver; color: blue">new </span><span style="background: silver; color: #2b91af">SqlConnection</span><span style="background: silver">(strConnection);
                conn.Open();
            }
            </span><span style="background: silver; color: blue">catch </span><span style="background: silver">(</span><span style="background: silver; color: #2b91af">SqlException </span><span style="background: silver">ex)
            {
                DisplayErrors(ex);
                conn.Close();
            }
        }

        </span><span style="background: silver; color: blue">private void </span><span style="background: silver">btnClick_Click(</span><span style="background: silver; color: blue">object </span><span style="background: silver">sender, </span><span style="background: silver; color: #2b91af">EventArgs </span><span style="background: silver">e)
        {
            </span><span style="background: silver; color: blue">string </span><span style="background: silver">strSQL = </span><span style="background: silver; color: #a31515">&quot;Select [CompanyName],[ContactName] from Customers&quot;</span><span style="background: silver">;
            </span><span style="background: silver; color: blue">try
            </span><span style="background: silver">{
                cmd = </span><span style="background: silver; color: blue">new </span><span style="background: silver; color: #2b91af">SqlCommand</span><span style="background: silver">(strSQL, conn);
                dr = cmd.ExecuteReader(</span><span style="background: silver; color: #2b91af">CommandBehavior</span><span style="background: silver">.SequentialAccess);

                </span><span style="background: silver; color: blue">while </span><span style="background: silver">(dr.Read())
                {
                    lstCustomers.Items.Add(dr.GetString(1));
                }
            }
            </span><span style="background: silver; color: blue">catch </span><span style="background: silver">(</span><span style="background: silver; color: #2b91af">SqlException </span><span style="background: silver">ex)
            {
                DisplayErrors(ex);
            }
            </span><span style="background: silver; color: blue">finally
            </span><span style="background: silver">{
                dr.Close();
                conn.Close();
            }
        }

        </span><span style="background: silver; color: blue">private void </span><span style="background: silver">DisplayErrors(</span><span style="background: silver; color: #2b91af">SqlException </span><span style="background: silver">errSQLException)
        {
            </span><span style="background: silver; color: blue">for </span><span style="background: silver">(</span><span style="background: silver; color: blue">int </span><span style="background: silver">i = 0; i &lt; errSQLException.Errors.Count; i++)
            {
                </span><span style="background: silver; color: #2b91af">MessageBox</span><span style="background: silver">.Show(</span><span style="background: silver; color: #a31515">&quot;Index # &quot; </span><span style="background: silver">+ i + </span><span style="background: silver; color: #a31515">&quot;\n&quot; </span><span style="background: silver">+ </span><span style="background: silver; color: #a31515">&quot;Error:&quot; </span><span style="background: silver">+ 
                    errSQLException.Errors[i].ToString() + </span><span style="background: silver; color: #a31515">&quot;\n&quot;</span><span style="background: silver">);
            }
        }
    }
}</span></pre>

<pre class="code">Happy Programming!</pre>]]></content:encoded>
    </item>
    <item>
      <title>Windows PowerShell and .NET Together (creating the object)</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/windows-powershell-and-net-together-creating-the-object</link>
      <pubDate>Mon, 27 Apr 2009 17:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/04/27/windows-powershell-and-net-together-creating-the-object/</guid>
      <description><![CDATA[By this time, you are probably aware of the fact that the Windows PowerShell integrates with the...]]></description>
      <content:encoded><![CDATA[<p>By this time, you are probably aware of the fact that the Windows PowerShell integrates with the Microsoft .NET Framework very well and leverages it power fully. So, if you are new to PowerShell and don’t know much about PowerShell scripting, you can still go ahead and use its power by relying on the old .NET framework (which I suppose you are very good at :))</p>  <p>Here is the code snippet, which demonstrates how to create class, object and functions using C# and executes in Windows PowerShell:</p>  <p>=========================================================</p>  <p>Add-Type @' </p>  <p>public class Calculator   <br>{    <br>&nbsp;&nbsp;&nbsp; public double AddNumber(double x, double y) {    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x + y;    <br>&nbsp;&nbsp;&nbsp; } </p>  <p>&nbsp;&nbsp;&nbsp; public double SubtractNumber(double x, double y) {   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x - y;    <br>&nbsp;&nbsp;&nbsp; } </p>  <p>&nbsp;&nbsp;&nbsp; public double MultiplyNumber(double x, double y) {   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x * y;    <br>&nbsp;&nbsp;&nbsp; } </p>  <p>&nbsp;&nbsp;&nbsp; public double DivideNumber(double x, double y) {   <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return x / y;    <br>&nbsp;&nbsp;&nbsp; }    <br>}    <br>'@ </p>  <p>$dblX = read-host "Enter the first number"   <br>$dblY = read-host "Enter the second number" </p>  <p>$objCalculator = New-Object Calculator   <br>write-host "Sum--&gt;" $objCalculator.AddNumber($dblX,$dblY)    <br>write-host "Difference--&gt;" $objCalculator.SubtractNumber($dblX,$dblY)    <br>write-host "Multiplication--&gt;" $objCalculator.MultiplyNumber($dblX,$dblY)    <br>write-host "Division--&gt;" $objCalculator.DivideNumber($dblX,$dblY)</p>  <p>=========================================================</p>  <p>Copy the above code in a file and save it with an extension “ps1” e.g. “Calculator.ps1” and then run it from the PowerShell command prompt.</p>  <p>Happy Programming!</p>]]></content:encoded>
    </item>
    <item>
      <title>How to check programmatically if a website is running</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/how-to-check-programmatically-if-a-website-is-running</link>
      <pubDate>Thu, 23 Apr 2009 12:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/04/23/how-to-check-programmatically-if-a-website-is-running/</guid>
      <description><![CDATA[Recently, I got a request from one of my partners to check if a particular website is running or not...]]></description>
      <content:encoded><![CDATA[<P align=left>Recently, I got a request from one of my partners to check if a particular website is running or not and this has to be done from a windows service; which should be checking automatically at a given interval once started.</P>
<P align=left>Well, you can use WebRequest and WebResponse Classes (under namespace System.Net) to first create a request object for the particular website and then use the GetResponse() function to check if any response has been sent from the web site.</P>
<P align=left>More information about the WebRequest and WebResponse classes can be found here:</P>
<P align=left><A title=https://msdn.microsoft.com/en-us/library/system.net.webresponse.aspx href="https://msdn.microsoft.com/en-us/library/system.net.webresponse.aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.net.webresponse.aspx">https://msdn.microsoft.com/en-us/library/system.net.webresponse.aspx</A></P>
<P align=left>Here is the code snippet for the windows service which checks every 1 min for a particular website running status:</P>
<P align=left>----------------------------------------------------------------------------------------------------</P>
<P align=left>using System; <BR>using System.ComponentModel; <BR>using System.Diagnostics; <BR>using System.ServiceProcess; <BR>using System.Threading; <BR>using System.Timers; <BR>using System.Net; </P>
<P align=left>namespace DemoWinService <BR>{ <BR>&nbsp;&nbsp;&nbsp; partial class CheckWebApp : ServiceBase <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TimerCallback objTimerCallBack; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Timer objStartTimer; </P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CheckWebApp() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponent(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override void OnStart(string[] args) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Add code here to start your service. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartChecking(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; protected override void OnStop() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Add code here to perform any tear-down necessary to stop your service. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void StartChecking() <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objTimerCallBack += new TimerCallback(WebSiteCheck); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objStartTimer = new System.Threading.Timer(objTimerCallBack, null,0,60000); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void WebSiteCheck(object obj) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebRequest objRequest = WebRequest.Create("<A href="https://www.contoso.com%22);/" mce_href='https://www.contoso.com");'>https://www.contoso.com");</A></P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebResponse objResponse = objRequest.GetResponse(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(objResponse.ContentLength &gt; 0) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventLog.WriteEntry("Success-&gt;" + objResponse.ContentLength.ToString()); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventLog.WriteEntry("Website is not running."); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objResponse.Close(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;&nbsp; } <BR>}</P>
<P align=left>----------------------------------------------------------------------------------------------------</P>
<P align=left>However, while installing (many times) the windows service I got installation errors; I checked in the “services windows” and found that the my service was not fully uninstalled and when tried to change the properties, I got an error “The specified service has been marked for deletion.” To overcome that error you can try closing the services windows and reopen it. If that doesn’t work then try rebooting the machine.</P>
<P align=left>You can however,&nbsp;use HttpWebRequest and HttpWebResponse classes to check the status of the website if it is running successfully or not by checking the server status (no bad request or server error etc):</P>
<P align=left>The&nbsp;WebSiteCheck function&nbsp;will look like this</P>
<P align=left>---------------------------------------</P>
<P align=left>&nbsp;private void WebSiteCheck(object obj)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("<A href="https://www.contoso.com/">https://www.contoso.com</A>");</P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();</P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((objResponse.StatusCode == HttpStatusCode.OK) &amp;&amp; (objResponse.ContentLength &gt; 0))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventLog.WriteEntry("The length of the data is " + objResponse.ContentLength.ToString() + " and the status code is " + objResponse.StatusCode.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EventLog.WriteEntry("Website is not running.");</P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objResponse.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;</P>
<P align=left mce_keep="true">----------------------------------</P>
<P align=left>Happy Programming!</P>]]></content:encoded>
    </item>
    <item>
      <title>The power of PowerShell: Working with ADO.NET Data Services and JSON</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/the-power-of-powershell-working-with-ado-net-data-services-and-json</link>
      <pubDate>Wed, 08 Apr 2009 13:20:56 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2009/04/08/the-power-of-powershell-working-with-ado-net-data-services-and-json/</guid>
      <description><![CDATA[A very interesting article to read on working with JSON data with PowerShell on “gduthie” blogs:...]]></description>
      <content:encoded><![CDATA[<p>A very interesting article to read on working with JSON data with PowerShell on “gduthie” blogs:</p>  <p>ADO.NET Data Services, JSON, and PowerShell </p>  <p><a title="https://blogs.msdn.com/gduthie/archive/2009/04/08/ado-net-data-services-json-and-powershell.aspx" href="https://blogs.msdn.com/gduthie/archive/2009/04/08/ado-net-data-services-json-and-powershell.aspx">https://blogs.msdn.com/gduthie/archive/2009/04/08/ado-net-data-services-json-and-powershell.aspx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Useful resources on SQL Server Compact Edition</title>
      <link>https://docs.microsoft.com/archive/blogs/vijay/useful-resources-on-sql-server-compact-edition</link>
      <pubDate>Thu, 20 Dec 2007 18:58:00 GMT</pubDate>
      <dc:creator><![CDATA[Vijay-MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/vijay/2007/12/20/useful-resources-on-sql-server-compact-edition/</guid>
      <description><![CDATA[SQL Server Compact Edition Concepts
A Technical Comparison of Replication and Remote Data Access...]]></description>
      <content:encoded><![CDATA[<P><A class="" title=_Toc165383096 name=_Toc165383096></A><B>SQL Server Compact Edition Concepts</B><B></B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms345126.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms345126.aspx">A Technical Comparison of Replication and Remote Data Access Features in SQL Server 2005 Mobile Edition 3.0</A></P>
<P><A class="" title=_Toc94085555 name=_Toc94085555></A><A class="" title=_.NET_Development_Resources name=_.NET_Development_Resources></A><A class="" title=_XML_and_Web_Service_Resources name=_XML_and_Web_Service_Resources></A><A class="" title=_Miscellaneous_Resources name=_Miscellaneous_Resources></A><A href="https://msdn2.microsoft.com/en-us/library/ms838177.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms838177.aspx">Architecting Disconnected Mobile Applications Using a Service Oriented Architecture</A></P>
<P><A href="https://blogs.msdn.com/stevelasker/rss_tag_SQLev.xml" mce_href="https://blogs.msdn.com/stevelasker/rss_tag_SQLev.xml">Q&amp;A on OCS &amp; Sync Services for ADO.NET</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172368.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172368.aspx">How Remote Data Access Works</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171846.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171846.aspx">Planning for Remote Data Access</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171761.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171761.aspx">Implementing Remote Data Access</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172367.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172367.aspx">Using Merge Replication</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172431.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172431.aspx">Planning for Replication (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171850.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171850.aspx">Implementing Replication (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms174014.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms174014.aspx">SQL Server Compact Edition Replication Programming</A></P>
<P><B><I></I></B></P>
<P><A class="" title=_Toc165383097 name=_Toc165383097></A><B>Enhancing Performance</B><B></B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172432.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172432.aspx">Database Design and Performance (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172984.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172984.aspx">Query Performance Tuning (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/bb190959.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/bb190959.aspx">Optimizing Connectivity (SQL Server Compact Edition)</A></P>
<P><A class="" title=_Toc165383098 name=_Toc165383098></A><B><I></I></B></P>
<P><B>User Interface Reference (SQL Server Compact Edition)</B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172034.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172034.aspx">Server Tools Setup Wizard Help (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171862.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171862.aspx">Configure Web Synchronization Wizard Help</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172386.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172386.aspx">New Subscription Wizard Help</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172460.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172460.aspx">SQL Server Compact Edition Management Dialog Help in SQL Server Management Studio</A></P>
<P><A class="" title=_Toc165383099 name=_Toc165383099></A><B><I></I></B></P>
<P><B>How To (SQL Server Compact Edition)</B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171736.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171736.aspx">Installation Tasks (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172004.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172004.aspx">Performing Common Database Tasks (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172931.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172931.aspx">Replication and RDA Tasks (SQL Server Compact Edition)</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172076.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172076.aspx">Securing the Database Environment (SQL Server Compact Edition)</A></P>
<P><A class="" title=_Toc165383100 name=_Toc165383100></A><B>Securing Databases (SQL Server Compact Edition)</B><B></B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171741.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171741.aspx">Password Protecting a Database</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms172901.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms172901.aspx">Encrypting a Database</A></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms171786.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms171786.aspx">Changing Passwords and Encryption Settings for a Database</A></P>
<P><A class="" title=_Toc165383101 name=_Toc165383101></A><B>Windows Mobile 5.0 Application Security</B><B></B></P>
<P><A href="https://msdn2.microsoft.com/en-us/library/ms839681.aspx" mce_href="https://msdn2.microsoft.com/en-us/library/ms839681.aspx">https://msdn2.microsoft.com/en-us/library/ms839681.aspx</A></P>
<P><A href="https://www.microsoft.com/technet/solutionaccelerators/mobile/maintain/SecEntMessaging/4ea10143-5661-45c7-a26b-d01070e3632b.mspx?mfr=true" mce_href="https://www.microsoft.com/technet/solutionaccelerators/mobile/maintain/SecEntMessaging/4ea10143-5661-45c7-a26b-d01070e3632b.mspx?mfr=true">Security Considerations on the Device</A></P>
<P><A href="https://www.microsoft.com/technet/solutionaccelerators/mobile/maintain/SecEntMessaging/1f87280c-ceb9-451a-b7c1-056bd3225624.mspx" mce_href="https://www.microsoft.com/technet/solutionaccelerators/mobile/maintain/SecEntMessaging/1f87280c-ceb9-451a-b7c1-056bd3225624.mspx">Security Risks in the Mobile Enterprise</A></P>]]></content:encoded>
    </item>
  </channel>
</rss>