Wednesday, March 9, 2016

Intro to the Internet of Things using Netduino

This was my presentation to the .Net Users of Fort Wayne (NUFW) on 3/8/2016.


Index Reorganization and Rebuilding for Success

On January 20, I presented an end-to-end process for SQL Server Index rebuilding/reorganization to NUFW (.Net Users of Fort Wayne). For people that manage small databases with less than a few million records per table, there are few risks and considerations. For those with large or VLDB databases such as ERP/MRP databases with hundreds of millions of records and Terabyte data file sizes, the process becomes more critical and time consuming. That is the situation for which this process was designed.


Wednesday, May 21, 2014

Powershell IDE’s

There are a number of free Powershell Development environments out there. So far, my favorite is Dell’s (formerly Quest Software’s) PowerGui. My current IDE of choice is Idera’s Powershell Plus. There are a few things I still use Microsoft’s native Powershell ISE for, but it doesn’t have all the features I am accustomed to from the other IDE’s. A few of my observations are summarized below, but since they are all free tools, I am appreciative of the value they provide.

Windows Powershell ISE

I like that it has the screen wipe button to clear the console, but since I work more in PowerGUI and Powershell Plus, I am now accustomed to putting a CLS command at the top of my scripts to clear the screen between executions.

There is an x86 version and x64 version which makes working with older 32bit dll’s like the SAP Business Objects 3.1 .Net API’s easy.

In the versions I used there didn’t appear to be much if at all in terms of Intellisense (code completion options). Because I switch between editors for VB.Net, C#, Powershell, and SQL Server, Intellisense is a desirable feature to improve productivity.

Powershell Plus

It took me a while to find all the options to set up the environment the way I like it (more like the default PowerGUI interface). It has more bells and whistles than PowerGUI, but most of the time I don’t really need all that. Mainly I just want the code window, console output window, and the variables list.

I do like the debugging functionality which automatically steps one line at a time through the code pausing briefly so you can see what line it is currently executing.

I don’t like how the comment/uncomment works. It uses a paragraph style comment block vs. commenting individual lines which means I can’t selectively uncomment only a few lines in the bulk paragraph block. Also I can’t uncomment the whole block unless I select exactly the correct selection.

There are more options for Executing the scripts, but that seems to take more clicks to Execute in the manner I want to use while testing.

I am still relatively new to Powershell Plus so my productivity will improve as I become more familiar with its IDE design.

PowerGUI

This is my favorite, but my issue with it is it doesn’t appear they are actively developing it since Dell acquired it from Quest Software. It hasn’t had an update in a few months and the version I have installed won’t uninstall and I can’t install the newest release without error. The Intellisense is pretty good.

I like how the comment/uncomment functionality works. It works like Visual Studio and SQL Server where it will comment or uncomment exactly which lines are highlighted, even if only a part of the line is highlighted.

When typing a file path, the GUI makes it easy to click on the path and finish completing the path by navigating the folder structure with a Windows Explorer Browse like functionality.

I like the options for Execute All and Execute selection. There are buttons for them right on the top menu as well as the right click menu.

Links

Dell PowerGUI

Idera Powershell Plus

Windows Powershell ISE

Wednesday, April 16, 2014

SQL Server Daily Health Check page and Powershell script update

I recently created a new page for my SQL Server Daily Health Check Powershell script download and documentation. I updated the script to version v0.8.2 which refactored the original script into a function to eliminate repeating code and make it easier to customize with additional checks. I will add additional documentation and instructions as I get time.

Wednesday, February 12, 2014

Stop Main Page from Scrolling on iPad within Scrolling ModalPopup

Using ASP.Net ModalPopupExtenders can improve the user experience, but sometimes introduce some annoying side effects on a Mobile device. On a Mobile device like an iPad, if you have a ModalPopup that has more content than fits the screen, it can require having a scrollbar within the popup. If the main page is also too long for the screen, the main page can have a scroll bar also. The user experience degrades when on an iPad, the user is scrolling down the popup content and they reach the bottom of the popup, continued swiping up to scroll down will then start scrolling the main page down. If the user wants to scroll back up within the popup, they must repeatedly swipe down to first scroll the main page up until the top of the main page is reached at which point the popup content will start scrolling up.

There are a number of search results that “remove the scrollbar” from the main page while the modal popup is open by setting the html and body CSS tags to overflow:hidden, but many mobile devices don’t respect overflow:hidden alone. I found it was also necessary to set position:fixed also. When the popup is closed reset the position to static or inherit and set overflow to auto. I used jQuery to change the CSS tags to hide and show the main page scroll bars.

In my example, I had a div tag with id=”wrapper” in the Master Page surrounding the main page content. I had a ModalPopup window in the WebForm containing a Label (blank text) with a CssClass=”promoVisible” and an OK button with the CssClass=”popupOk”. On the WebForm with the Modal Popup, I used the following jQuery that does all the magic.

$(document).ready(function () {


//had to set position:fixed to work on iPad and other mobile    


   $('.popupOk').click( function(){


      $('#wrapper').css('overflow', 'auto');


      $('#wrapper').css('position', 'inherit');


      //  alert("ok clicked");


   });


   // if the popup is visible, fix the overflow so the


   // background doesn't scroll, only the popup window


   if($('.promoVisible').is(':visible')){


      $('#wrapper').css('overflow', 'hidden');


      $('#wrapper').css('position', 'fixed');


   } else{


      $('#wrapper').css('overflow', 'auto');


      $('#wrapper').css('position', 'inherit');


   }


)};




 

Sunday, April 7, 2013

Publish Documents to SAP Infoview using Powershell

SAP offers reasonable guidance for creating and publishing the various reports (Webi, pdf, Excel, Crystal Reports) using custom web or windows applications that consume their SAP .Net Development SDK.

Using those tools one can create user friendly applications for managing reports in Infoview, but in some cases you may need an easily customizable process for automating some of those tasks. System administrators everywhere are finding Powershell to be a ideal tool administration and automation.

Prerequisites/Assumptions

  • SAP Business Objects 3.1 (BOXI 3.1)
  • User account running Powershell has appropriate permissions to access the fileshare where the source pdf report is located
  • Have account credentials with permissions to read/write files on the Bobj API server
  • 32bit Powershell x86 engine
  • Server or PC running the Powershell script has the SAP Business Objects .Net SDK installed

Powershell script

# -------------------------------------------------
# Must use x86 powershell client for BOXI 3.1 dll's
# -------------------------------------------------
[reflection.assembly]::LoadWithPartialName("CrystalDecisions.Enterprise")
[reflection.assembly]::LoadWithPartialName("CrystalDecisions.Enterprise.InfoStore")
[reflection.assembly]::LoadWithPartialName("CrystalDecisions.Enterprise.Desktop.Pdf")
[reflection.assembly]::LoadWithPartialName("CrystalDecisions.Enterprise.Framework")

#[CrystalDecisions.Enterprise.SessionMgr] | Get-member

$username = "<cmsUsername>"
$password = "<cmsPassword>"
$cmsname = "<cms-servername>:6400"
$cmsAuthType = "secEnterprise"
$BOServerName = "<Bobj-servername>"

[CrystalDecisions.Enterprise.SessionMgr]$boSessionMgr = New-Object CrystalDecisions.Enterprise.SessionMgr
[CrystalDecisions.Enterprise.EnterpriseSession]$boEnterpriseSession = $boSessionMgr.Logon($username, $password, $cmsname, $cmsAuthType)
[CrystalDecisions.Enterprise.EnterpriseService]$boEnterpriseService = $boEnterpriseSession.GetService("", "Infostore")

$boInfoStore = New-object CrystalDecisions.Enterprise.InfoStore($boEnterpriseService)
$myInfoObjects = $boInfoStore.NewInfoObjectCollection()
$myPluginManager = $boInfoStore.PluginManager
$myPluginInfo = $myPluginManager.GetPluginInfo("CrystalEnterprise.PDF")

$myInfoObject = $myInfoObject = $myInfoObjects.Add($myPluginInfo)
$myPDF = [CrystalDecisions.Enterprise.Desktop.Pdf]$myInfoObject
$myPDF.Title = "DeanPowershelling"
$myPDF.Properties.Add("SI_PARENTID", "4701")
$myPDF.Description = "Dean is testing uploading to Infoview with Powershell"
$myPDF.Files.Add("C:\Development\sapmnt\Reporting\Report-to-be-published.PDF")

$boInfoStore.Commit($myInfoObjects)

# clean up
$boEnterpriseSession.Logoff()
$boEnterpriseSession.Dispose()
$boSessionMgr.Dispose()
$boInfoStore.Dispose()


The example above is written for Pdf files, but the syntax for the other document types is very similar. Since this is Powershell, it would be a relatively simple task to convert the above to a Powershell Function that could be used by piping the results of some automation to the function to upload a collection of reports at a time, vs. the one-off approach above.



Troubleshooting



I initially assumed that because I had BusinessObjects installed on my development environment where I was testing, that I had the appropriate dll’s in the GAC to instantiate the BO objects in Powershell. That lead me down a rabbit hole of troubleshooting where I had difficulty determining if the issues I was having were related to the syntax I was trying to use in Powershell or the lack of the necessary BO assemblies.



I experimented with a combination of copying the dll’s from a working .Net web application to a local folder and using the Powershell Add-Type –path syntax to load the assemblies. I used Telerik JustDecompile to browse the SAP .Net SDK assemblies to make sure I wasn’t missing assemblies.



I downloaded and installed the SAP BusinessObjects .Net Development SDK’s. Some time during the troubleshooting I was successfully using the Powershell Add-Type –AssemblyName syntax, but I must have had the assemblies loaded from previous debugging attempts because after a restart of the development box, the script using Add-Type –AssemblyName to load the assemblies was failing to recognize the CrystalDecisions.Enterprise.SessionMgr which is actually a part of CrystalDecision.Enterprise.Framework which I was not loading in the PS1 script prior to the restart. The [reflection.assembly]:LoadWithPartialName was working with the above referenced assemblies even after a restart.



In order to step though and make sure my assemblies were referenced and loaded correctly, I used the above commented out syntax of BO object piped to the Get-Member commandlet to list the methods and properties on the BO objects:



[CrystalDecisions.Enterprise.SessionMgr] | Get-member 


If the methods were listed without error, I knew I had the assembly references correct and the assemblies were loaded.


This is important enough to repeat, make sure if you are using the BOXI 3.1 SDK assemblies, you use an x86 32-bit Powershell engine. 


Disclaimer: Make sure all interface with your SAP platform services is in compliance with your applicable SAP license agreements.

Visual Studio Productivity Tools

This is the shell of a presentation I created to highlight some Visual Studio extensions that I have found helpful for improving my coding productivity in Visual Studio 2012.

The extensions can be downloaded from NUGET using Tools – Extensions and Updates – Online – Visual Studio Gallery:

  • Productivity Power Tools 2012 by Microsoft
  • Web Essentials 2012 by Mads Kristensen

Introduction to Powershell presentation

Powershell is a powerful scripting shell to do any number of administrative tasks. Below is the introductory level presentation I gave to fwPASS, the Fort Wayne chapter of the Professional Association for SQL Server on 10/23/2012.

Wednesday, June 20, 2012

Hyper-V Manager cannot connect–make sure RPC service is running

My Hyper-V Server 2008R2 lab environment is so stable I rarely fire up the Hyper-V MMC snap-in. The last time I opened it was four months ago when I switched from booting it from a USB stick to booting it from an IDE drive. I opened it today and it gave me the typical “Cannot connect to the RPC service on computer 'Servername'. Make sure your RPC service is running.” error. My quick troubleshooting steps follow:

  1. I double checked to make sure the IP address and host name were still specified in the \etc\hosts file. It was.
  2. I attempted to remote into the Hyper-V server directly using Remote Desktop and was met with the “Your password has expired” message. I reset the password, and voila – the Hyper-V manager MMC connected to my server and displayed the current state of my VM’s.

Tuesday, June 19, 2012

Blank Page when Publishing a Silverlight App

I just deployed a new Silverlight application to a Windows Server 2003 box as a new website and was surprised with a blank page when I launched the application. No error messages or warnings, just a completely blank page.

A quick web search and I realized I had been here before. You have to register the MIME types, .xaml and .xap, in IIS for the website. I added them for a previous website, but I didn’t add them at the server root.

Simple instructions to add the MIME types to IIS can be found on Jacqui’s Dev Blog under Deploying Silverlight Application - Why Blank?! Note the first blog post comment that suggests adding the additional .xap application/x-silverlight-app and .xbap application/x-ms-xbap MIME types. I didn’t need to add the .xbap to get my application working, but I did need the .xap.

Wednesday, June 6, 2012

Visual Studio Project – unavailable

one broken pencil tip in a setI hadn’t opened a particular Visual Studio solution since getting a replacement workstation and rebuilding my developer environment. Upon opening, one of the projects in the solution would not open and showed up as “(unavailable)” as shown below.

vs 2010 project (unavailable)

The Output window displayed the not very useful message, “The project type is not supported by this installation.”

project type not supported

In order to find out why, I opened the LPM.csproj file using Wordpad, not in Visual Studio, and scanned through the properties looking for insight as to why the project was unsupported. It didn’t take long to find the issue.

This project was using MVC 3 and the Entity Framework 4.1 which were not installed on my new workstation. I installed EF 4.1 on my old workstation specifically so I could use the MvcScaffolding NUGET package with an existing database design for a product technology upgrade. See my previous posts detailing some of my experiences with MvcScaffolding and the ASP.NET MVC framework.

missing-EF-4.1

After installing both ASP.NET MVC 3 and EF 4.1, all the projects in the solution opened as expected. Another small victory!

 

photo credit: ruurmo / CC BY-SA 2.0

Tuesday, May 29, 2012

Sterling Serialization issue - Object of type 'System.Int32' cannot be converted to type 'System.DateTime'

sterling forksI created a new data model class to store in a Sterling NoSQL database. On the first and all subsequent attempts to save or retrieve data of this type, I received the error message at the bottom of this post. A number of other people reported similar issues. Apparently it is some type of serialization/deserialization issue. I didn’t find a suggested resolution, but on a whim, moved the AssessmentDate DateTime property from the top of the list of properties in the class to the bottom and that seemed to resolve the issue.

class definition

Object of type 'System.Int32' cannot be converted to type 'System.DateTime'.

   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Wintellect.Sterling.Serialization.PropertyOrField.<get_Setter>b__0(Object obj, Object prop)
   at Wintellect.Sterling.Serialization.SerializationHelper.<>c__DisplayClassd.<_CacheProperties>b__5(Object parent, Object property)
   at Wintellect.Sterling.Serialization.SerializationHelper.Load(Type type, Object key, BinaryReader br, CycleCache cache)
   at Wintellect.Sterling.Database.BaseDatabaseInstance.Load(Type type, Object key, CycleCache cache)
   at Wintellect.Sterling.Database.BaseDatabaseInstance.Load(Type type, Object key)
   at Wintellect.Sterling.Database.BaseDatabaseInstance.Load[T,TKey](TKey key)
   at Wintellect.Sterling.Keys.TableKey`2.<.ctor>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at LeanAssessmentNav.Views.Register.<BindLists>b__6(TableKey`2 a)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at LeanAssessmentNav.Views.Register.BindLists()
   at LeanAssessmentNav.Views.Register..ctor()

 

photo credit: Le Petit Poulailler / CC BY 2.0

Why isn’t my Sterling database persisting between application loads?

Sterling repository (silver bowl)I’m using Sterling, a NoSQL database for .Net, Silverlight, and Windows Phone, to persist some data in a Silverlight 4 application. The intent is to persist it using Isolated Storage. It was obvious that the data was temporarily persisting because the stored data was available on multiple different views in the application. The trouble showed up when I stopped debugging and later started debugging again, the application re-launched and none of the previously persisted data was available.

Initially I was thinking that using the Visual Studio ASP.Net Development server was not maintaining Isolated Storage between application launches. It was far more simple than that. By default, Sterling uses an in-memory driver. If you want to persist using Isolated storage, you must pass an instance of the IsolatatedStorageDriver as an argument when Registering the Database. Note the difference in the samples below.

In Memory

Database = _engine.SterlingDatabase.RegisterDatabase<YourSterlingDatabase>();

Isolated Storage

Database = _engine.SterlingDatabase.RegisterDatabase<YourSterlingDatabase>(new Wintellect.Sterling.IsolatedStorage.IsolatedStorageDriver());

 

photo credit: Neil Noland / CC BY-SA 2.0

Wednesday, April 11, 2012

Get Started Using NuGet on Visual Studio 2010

You’ve been hearing things about NuGet, but aren’t sure where it is our how to use it. This is a basic instruction on how to get started.

Why NuGet? Developer Productivity. It makes it easier to do things like add Asp.Net Ajax or other libraries and utilities to your project without constantly searching the web for the download and installation process. It is great for items you add to your solutions regularly, but don’t always remember the steps because it has been a while since the last time.

NuGet

  1. Go to NuGet.org to download and install NuGet, a Visual Studio extension that makes it easier to download and install third party libraries in a Visual Studio project.
  2. Restart Visual Studio, if you had it open.
  3. Open the project you want to add the utility or library to.
  4. Click “Manage NuGet Packages” under the Visual Studio 2010 “Project” menu. image
  5. Search for a utility you are interested in, such as “AjaxControlToolkit”, “Modernizr”, or “MvcScaffolding”.
  6. Click the “Install” button.

Wednesday, March 28, 2012

Uninstalling a Failed SQL Server 2008 Installation

frustrationLast night at a SQL Server User Group meeting, one of the attendees was describing the trouble he was having uninstalling a failed SQL Server installation. There was some kind of problem that caused it to fail on the database engine installation. That sounded exactly like a problem I had installing SQL Server 2008R2 as a named instance alongside SQL Server 2005 just a few weeks before.

My installation was failing because I was attempting to install SQL Server 2008 (not R2) from an actual Microsoft DVD (most of the time I am installing from an MSDN iso download). After much of the installation was complete, a dialog popped up prompted for media containing a path to a SQL Server 2008 R2 executable. I wasn’t trying to install R2, so I’m not sure why the prompt. I ignored the prompt and continued the installation which failed (no surprise there). After the error, I decided I would just uninstall the non-R2 instance and install SQL Server 2008 R2, but the uninstall wizard would not work.

For posterity sake, the blog post that I used to uninstall the failed installation was Fun with software : uninstalling SQL Server 2008 R2 Evaluation Edition by Aaron Bertrand. The article is about uninstalling an eval edition, but it worked for me on an RTM or SP1 copy.

 

photo credit: peterhess / CC BY 2.0

Tuesday, February 28, 2012

Hyper-V Lab Experiment; Attack of the Snapshots

DeLorean time machineThis is a brief chronicle of the effect of re-creating a Virtual Machine from a Virtual Hard Drive that had Snapshots taken and not merged back into the parent image.

Background

In August 2010, I created a Hyper-V lab with a Windows 7 development VM and a Server 2008R2 testing VM. The VM hard disks, virtual machines, and snapshots were stored on the SATA hard disk. The Hyper-V Server 2008R2 host was installed on a bootable USB pen drive.

Apparently around November 2010 and over the course of 2011 I created a few snapshots of the Windows 7 VM.

Fast forward to a couple weeks ago

My Hyper-V environment lost power and when it restarted the BIOS failed to recognize the Kingston USB pen drive that Hyper-V was booting from. Result: My lab was down. This happened one other time, but after some fiddling with the BIOS, I  was able to get the USB drive to be recognized.

In order to prevent this from happening in the future, I replaced the USB pen drive by installing Hyper-V Server 2008R2 on an IDE drive, plugged it into my lab box and booted. I created a new Virtual Machine using the existing Window 7 Virtual Hard Drive and powered up my development VM. Upon a quick glance everything looked fine.

Missing Files and Programs

A few days later while logged into my Dev VM, I noticed several of my files and directories were missing, Microsoft Office wasn’t installed, and SQL Server said the trial had expired. What?!?

A quick check of the Windows Event log and there was an entry that Windows was not shut down properly on November 11, 2010, but was back up and running on Feb 12, 2012. Suddenly I was missing over a year of development activity; not really. 

Don’t Panic!

November 11, 2010 was the date the first snapshot was taken. All the activity since then was in the snapshot differencing disks (3 files with a .AVHD extension).

I had a Windows Image Backup and regular full backups, but instead of restoring from backup, I decided to have a little fun with the Hyper-V management console instead.

A little research and I found this article about merging differencing disks. It isn’t the best reference you can find because it doesn’t have screenshots of the process like this one. I actually backed up the parent VHD and child AVHD files and renamed the AVHD files VHD, but it appears the renaming process is unnecessary. Otherwise after using the Hyper-V management console to merge each of the AVHD files to their parent drives, I powered up the dev VM after merging and everything was back to the state prior to the initial power outage. Success!

Moral of the Story

If you use a Hyper-V snapshot to test a Windows Update or some other configuration change that you want to be able to roll back out of, make sure to merge the snapshot back into the VM. Don’t leave it in a snapshotted state. Especially not with multiple active snapshots.

Reference: Hyper-V: Avoid using differencing disks on virtual machines that run server workloads in a production environment.

photo credit: pnoeric / CC BY-SA 2.0

Thursday, February 16, 2012

Error 2337 Installing SQL Server 2008R2 in Virtual PC 2007

Issue

Last year I was preparing for an fwPASS presentation on Report Viewer 3.0 by installing SQL Server 2008R2 in a virtual machine using Virtual PC 2007. I kept getting an error 2337 indicating that the disk may have been corrupt or damaged. I was installing it from a .iso image I downloaded from my MSDN Ultimate subscription. I used the Virtual PC “capture iso image” functionality to mount the iso as a disk. I downloaded another copy of the iso image and repeated the process with the same results. Due to time constraints, I reverted back to SQL Server 2005 and Report Viewer 2.0 for that presentation, highlighting features new to 3.0 using screenshots.

Physical and Hyper-V Success

Since then I have successfully installed SQL Server 2008R2 successfully multiple times on bare metal physical servers and in VM’s using Hyper-V Server 2008.

VPC Still an Issue

Fast forward to this week. I was setting up a development sandbox in a VM. Again I was installing SS2008R2 by mounting the image in VPC 2007 and was faced with the same Error 2337. Seriously? This issue hasn’t been resolved yet? A quick search on the error resulted in this helpful post Getting error 2337 installing SQL Server on a VPC on the SQL Skills blog.

Solution

I didn’t have any blank DVD’s on hand for burning the image, so I decided I would use MagicDisc to mount the iso file on my host machine, instead of using VPC’s capture iso functionality. That solved the problem.

Tuesday, November 22, 2011

Troubleshooting Relative URI’s in Silverlight Projects

My Visual Studio Solution contains a minimum of a project for the Silverlight application and a project for the web page that hosts the Silverlight application. The Silverlight application reads and rights files to the local file system.

The solution is structured similar to this:

mySolution (has a minimum of the following two projects)

  • MyApplication.Web - the project that hosts the Silverlight xap file (could be a simple index.html page and Silverlight.js javascript page)
  • MyApplication - the Silverlight application project

When debugging in Visual Studio, the files that the Silverlight application is trying to read from are not necessarily available to the application depending on how you structure the application and which project you put the data files into initially.

While under development, intuition may lead you to believe that if it is the Silverlight application that is actually reading the files, the Data folder should be placed in the Silverlight application project root, not the web project. That would be incorrect.

Example 1

new Uri("/Data/ReadThisFile.xml", UriKind.Relative)

UriKind.Relative with a leading slash (/) in front of the Data folder is relative to the page that is hosting the XAP file. In my solution this is the project root of the web application, not the Silverlight project. The data file would be located at f:\mySolution\myApplication.Web\Data\ReadThisFile.xml


Example 2



new Uri("Data/ReadThisFile.xml", UriKind.Relative)
Without the leading slash in front of the Data folder as in this example, the file is expected to be relative to the Silverlight xap file. In my solution the xap file is in the default location, the ClientBin folder, which is a sub folder of the project root of the web application. The data file in this case would be located at f:\mySolution\myApplication.Web\ClientBin\Data\ReadThisFile.xml


Troubleshooting with Process Monitor


If you are getting File not found exceptions, the file isn’t where your application thought it was supposed to be. A relatively easy way to find out where the application is looking for the file is to use SysInternals Process Monitor.


Once you install and run the Process Monitor, you can set the filters to narrow down the captured events to locate the path to the file. The primary filters I used were “Result is not SUCCESS” and “Path contains ReadThisFile.xml”


 image


The filtered results would look similar to the following, if the the application throws a File not found type of error. (click to enlarge)


image

Monday, November 21, 2011

Could not load file or assembly System.IdentityModel

I added functionality to a Silverlight application I created several months ago and when I attempted to run it in debug mode, I received this error:

Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I found very little evidence of why I was getting this error now. My search results did not turn up much useful information either. I did find this link on Stack Overflow, so on a whim I revised the web.config of the web project that hosts the Silverlight application to a add a clear statement to the assemblies node.

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0" >
        <assemblies>
          <clear/>
        </assemblies>
      </compilation>
    </system.web>
</configuration>

After making that change, the assembly loads without errors. This was on my development workstation. The application did not throw any errors on the production server after publishing it without the clear statement in the web.config.