Get a copy of dll in GAC

1. February 2012

C:\Windows\assembly folder looks like this:

  1. Open up administrator CMD prompt and type.
  2. regsvr32 –u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll
  3. Now look in your folder and copy the dll you want.

 

When finish register the shfusion.dll again to restore the assembly where it was previously.

  1. regsvr32C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

Search for text in stored procedures

30. September 2011

I’m tried of searching for this all the time. So here is where I’m storing it. ^_^

 

SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION
    FROM INFORMATION_SCHEMA.ROUTINES
    WHERE ROUTINE_DEFINITION LIKE '%text%'
    AND ROUTINE_TYPE='PROCEDURE'
    ORDER BY ROUTINE_SCHEMA, ROUTINE_NAME

 

Just replace text with whatever you are looking for. But this does not search for functions or such.

SQL

IIK Series I–Software Construction Part 1 of 3

8. September 2011

Who should read this article:

Welcome to the first article in the IIK Series I. The main goal of each article is help you (and me) create higher-quality software and to complete our projects with fewer problems. I am hoping for the experience programmers will see this as a good guide. For the self-taught programmers, I hope to share new concepts and help give insight in topics you may not already know. For the students, I know you get a ton of theoretical knowledge, but this should help unbalance the biasness you get of the controlled environment of computer theory with the demand of practicality.

--------------------------------------------------------------------

Software Construction

1.1 What is Software Construction

1.2 Why is Software Construction Important

1.3 Determine the Kind of Software or Industry requirements you are working on.

1.4 Defining the Problem

1.5 Categorizing the Software Project

1.6 Meeting the Business needs of your Software Project

1.7 Construction Example

 

Related Topics:

Who should read these articles: Preface

---------------------------------------------------------------------

1.1 What is Software Construction?

Many books, articles will make analogies that software construction is a lot like building development. They port over concepts from building development into the software construction world. Many points are accurate, but some are not. The root problem that everybody should agree to is that computer software can be a complicated process.

To me programming is human thought codified and crystalized. Today's software metaphor normally relate software to buildings. There are others beside this metaphor, programming to math, programming as a model, or programming as rule-following. Given that my premise of programming is just raw human thought, then it stands to reason that some people are more apt towards this field then others are. That doesn't mean we can't train our brains or though process to be better focused towards this field. But it also means that there are those out there with slight advantages as a "master programmer." however the software industry does not only need "master programmers" just because you are a great problem solver does not mean you are somebody that can stand back and look at the larger picture. So in our field you also need the "Architect." Metaphors, design patterns and coding styles cannot replace actual intelligence, but they do help us to communicate to each other what it is we are trying to do. This is what Software Construction is about.

1.2 Why is Software Construction Important?

In our current market of today, construction is a major part of the Software Development Life Cycle. (SDLC), this is the life cycle of a software project with formalized stages for a start to finish solution. In the business world, it is a major part of their process.

Each software project you begin, you must realized there are four factors that effect that project;

  • Time
  • Resources
  • Quality
  • Features

 

At any given moment, you as the developer, own one of those four items. The other two are controlled by external sources. For example, say you have to complete this project in three months. You have customers flying in to train, or trainers flying out to train on your new feature/product. This is a hard date (meaning it can't be moved). Also the quality of the product must work as a finished product with very high quality requirements. In this situation you should be able to control how many resources it takes to get to this milestone.

  • For every project you work on you must pay the price of time. Either you pay for that time up front with some good construction design. Making your application scalable or flexible . Then when you do need to be handle changing something, because you designed your application with flexibility, you can easily "hook" into the existing code "interject" some new behavior at the right processing stage, debug, test and ship over to QA. (because we all know you don't just ship out to the customer without QA approval. That is what we call a "Hope Install.", and your customer should not be your first and last QA).

 

  • Most business stakeholders want you to finish the project faster and meet the requirements. Get it done and quickly. These people do not know that choice leads to greater bug time, as the developer will have to either refactor a lot of code to fit in the new changes. Let me put it to you another way business people. You tell me which is cheaper. When would you like to choose to move a elevator shaft if it ends up not being in the proper position. Would you choose to do this on paper while designing, or once it's completed. If you choose to do so once it's completed, it will be very expensive.

 

However there is a pitfall here. Anybody can sit down with a architect and produce a "specification" that, in truth does not adequately describe what the customer wants or what the requirements needs. This fact may not be apparent until after the customer sees the first demo of the software. Identifying these features and planning on them moving will money and time for all involved.

  • Many software projects fail because of weak specifications, not all of them, but enough to say.. Don't make weak specifications.
  • Many formally trained developers might over engineer and take way too much time for specifications that are not accurate. So don’t over engineer, just for the sake of making documentation.

 

My recommendation to you is, take some time to focus on the most critical 20% of your project core that needs to be worked out (thoughts onto paper) and then proceed with the project. This is a good general rule, but depending on the size of the project, may or may not be necessary. Large projects need more documentation, projects with more then three developers need more documentation to coordinate API's with each other. Small projects or one developer don’t need as much. It's a weighted scale and you must identify what is necessary to get the job done.

1.3 Determine the Kind of Software or Industry requirements you are working on.

Ask yourself what category does this project fit into?

  • Business Systems
    • Type of Projects: Internal, Intranet
    • Type of Work: As-needed testing and QA Planning, informal requirements, Design and coding are combined, Developers test their own code and little or no testing by separate test group, somewhat informal deployment procedure.

 

  • Core Systems
    • Type of Projects: Embedded Software, Packaged Software, Tools, Web Services
    • Type of Work: Staged delivery, up front planning, basic test planning, semiformal requirements, architectural designs documented, as-needed design reviews, code reviews, developers test their own code, separate testing group, formal deployment procedure.

 

  • Mission-Critical Systems
    • Type of Projects: Core Embedded Frameworks, Required Release Set Software
    • Type of Work: Staged Delivery, Extensive up-front planning, extensive QA test planning, Rigorous change control, Formal requirements specification, Architectural design, formal architecture inspections, formal detailed design, formal check-in procure, code reviews, developers test their own code, separate testing group, formal deployment procedure.

 

1.4 Defining the Problem

Defining the problem should be described from the user's point of view, not to be stated in technical computer terms. You don't want to tie the problem to specific technologies, because that may not be the best solution to the problem. If you list something like "Refactor stored procedures to solve performance problems." You are focusing on the specific area that may not be the problem at all. Instead the problem should be stated. "Performance problems when running client reports." This way you are not miscommunicating to the developer where the problem lies. Listing stored procedures may or may not be the solution.

1.5 Categorizing the Software Project

  1. Small Projects
    1. Less then 100,000 lines of code
  1. Medium Projects
    1. Greater than 100,000 lines of code and less than 3 million lines of code
  1. Large Projects
    1. Greater than 3 million lines of code

 

Lines of Codes of other projects

  • Windows NT 3.1 ( 4-5 Million)
  • Android OS (12 Million)
  • Windows Server 2003 (50 million)
  • Mac OS X (86 Million)

 

1.6 Meeting the Business needs of your Software Project

This is where you choose your technology you want to use to solve your software project. This includes the programming language, any third party libraries or technologies. Most times the programming language has been selected for you, so you might want to determine the type of classes you are going to use. Are you going to consistently use LINQ Query Syntax, or use long query syntax. Maybe you will use EJB's for Java, maybe not, or you might use WCF for .NET technologies.

What types of coding conventions do you follow? Good code should look like one developer wrote all of it, not pieced together from multiple developers. When choosing technologies if it's bleeding edge, realize that the community for it will not be mature. VS a mature community of a proven product or technologies which chances are that somebody already has tried what you are attempting to do. Be certain to choose the best software practices and tools that are best suited to your project.

1.7 Quick Construction example

Focus on documenting 20% of the Core requirements, do this by identifying the most critical components to achieve success. Focus on categorizing each component into three categories:

Lets say my company required me to create a listening web service for a partner to push massive amounts of data through so I can parse some information out of it, and build a held message for another project to pull from my storage cloud down to it's domain.

Identify your components

  • Focus on documenting 20% of the Core requirements, do this by identifying the most critical components to achieve success. Focus on categorizing each component into three categories:
  • Lets say my company required me to create a listening web service for a partner to push massive amounts of data through so I can parse some information out of it, and build a held message for another project to pull from my storage cloud down to it's domain.

 

Identify my components

  1. Listening Web Service: I choose WCF
  2. Partner Interface Method:  I choose to follow a standard in my industry name STAR Standard
  3. Extracting data - I will use LINQ Query Syntax
  4. Storing Message Structure - Build a project that handles dealing with Message Packets.
  5. Storage - Utilize Windows Azure Cloud
  6. Testing - Utilize a 3rd party tool. SOAPUI to mimic our partners message, use Azure storage explorer to see data in cloud
  1. Deploying -
    1. Dev - (Use host file to build a friendly name for dev testing purpose, no need to bother IT with outside dns) Azure also provides the Cloud Compute Emulator to simulate cloud on dev box
    1. Stage - Azure accounts each have staging and production. This can be combined for a "Dev Azure Account for my final testing"
    1. QA - Get a Domain Name alias (friendly name) to give to partner to use. Map to a "QA" Cloud account. Again there is a Staging and Production in the cloud, so no staging is necessary to configure.
    1. Production- Get a domain name alias (friendly name). Deploy to cloud
  1. Maintaining - What can I do to minimize having to redeploy for bug fixes? Research this with the cloud to see what I can use. Estimate: 6 hours for research. 3 for designing something if there is anything. After that.
  1. Recovery Plan - Research.

 

Focus on identifying the 20%

  • I know what I know (1 - lowest to 5 - strongest)
    1. (4) WCF
    2. (3) STAR Standard
    3. (4) LINQ Query Syntax - extracting data from where clause. No fancy queries foreseeable.
    4. (1) Azure Storage Cloud
    5. (3) SOAP UI
    6. (3) Azure Storage Explorer
  • I know what I don't know (this only focuses on what we actually have in the requirements)
    1. Customer data structure
    2. Performance of WCF in Cloud
    3. Integrating WCF with Web Role or Worker Roles of the Azure Cloud
    4. What types of configuration/power should I give to those that maintain this?
    5. Logging in the cloud. (Limitations?)
    1. Recovery if production is wiped out, how to rebuild this easily? Scripts? What?
  • I don't know what I don't know (these are the what if scenarios)
    1. Schema validation?
    1. Duplicate messages one to many?

     

    So from the look of things, I think I should probably focus my detailed documentation on what happens When I extract the data from the customer and how I'm storing the message. I might end up with a rough draft that looks something like this:

     

clip_image001_thumb3

1. Inputs to Public Azure Roles

  • PutMessageV1.svc : Called by IIK Series Partner to send information through. Message will parse information and create a unique address name.
  • ProcessMessageV1.svc: See PutMessageV1, exact same functionality.

 

2. Input to Internal Azure Roles

  • ReceiverV1.svc Receives structured data to store until pulled by another project.

 

3. Internal Azure Storage

  • Held Packet Table Held messages in Azure Storage.
  • Delivered Packet Table Once message has been delivered it is stored in this table for archiving or audit purposes as well as guaranteed delivery
  • Log Table Log table for storing log entries. 1_7Image_thumb[4]

 

This concludes Part 1 of Software Construction. In Part 2 we will be discussing some best practices on construction classes , methods and defensive programming as well as some code smells.

IIK Series

It Is Known Series

25. May 2011

I mostly use my website blog as a reference more then anything else. I’m still learning and new to blogging and I feel I still have a long way to go. It’s tough for me to find good new content to blog about. So in a new twist I think I’m going to start a string of series that explain intermediate and advanced topics about C# and other various technologies that I use in my career.

I hope that I can provide myself and others with some good blogging. Here is a rough estimate of the series I have planned for subsequent blogs. Interlaced with anything I feel might be important to blog about in-between.

IIK Series I

  • Software Construction
  • Object Orientated Programming
  • Events
  • C# Flow Control Suggestions
  • Exceptions oh my!
  • With and Without Generics
  • Multithreading and Thread Synchronization
  • Assemblies and Versioning
  • Algorthims
  • CLR

 

IIK Series II

  • Intro to WCF
  • Advanced WCF
  • WCF RESTful Services Project
  • WCF and Azure
  • WCF Best Practices

 

IIK Series III

  • Windows 7 Mobile Development Adventures (Coming soon..)

 

Architecture, Azure, C# Development, TechArticle

VS Tip–Incremental Search

11. March 2011

Most of us use Ctrl + F or Ctrl + Shift + F to find code. However you can also use a Ctrl + I which is the Incremental Search. The nice thing about this is you don’t have to wait for the dialog. Just hit Ctrl + i , and as you type it will match the string being typed.

Visual Studio

Visual Studio Break When Exception Thrown

11. March 2011

Maybe some of you know this, maybe some of you don’t. But I just learned about it. Apparently I’m a old man programmer because I normally just look at the code and try to solve it without debugging the application, or I write it out somewhere.

I’ve been trying to track down this wiggly bug in my factory pattern code, but it was a slippery bugger. I finally asked somebody for some help and they suggested that instead of all my try/catch’s I use the Break when Exception is thrown. By default Visual Studio only breaks when the exception is unhandled in the user code. For me this was some distance from where the exception was thrown.

So if you want to throw the error in the code where the error occurs and not wait for it to catch. You can select the Debug menu, then Exceptions (or use Ctrl-Alt-E) which will bring up this dialog box:

exceptions

Check the box under Thrown for the “Common Language Runtime Exceptions and viola. You are set.

Replacing NaN in XSLT 1.0

5. March 2011

As I was building a nice little XSLT I was encountering NaN (Not a Number) in my database. Here is the offending code.

<xsl:value-of select="number(string($RepairOrder/VehicleYear))"/>

This code can potentially return the NaN as a value because of the number function.

To solve this I used the test function in XSLT. My finally solution looks like this:

<Year>
   <xsl:choose>
      <xsl:when test="number(string($RepairOrder/VehicleYear)) 
!= number(string($RepairOrder/VehicleYear))
"> <xsl:number/> </xsl:when> <xsl:otherwise> <xsl:value-of select="number(string($RepairOrder/VehicleYear))"/> </xsl:otherwise> </xsl:choose> </Year>

 

Using the test I can determine that the resulting number NaN is not contained within my second express:

<xsl:when test="number(string($RepairOrder/VehicleYear)) 
!= number(string($RepairOrder/VehicleYear))
">

If it’s true I just set it to be the default number. Otherwise I pull the value of the number. To test this you can use the xslt test tool built into Visual Studio 2008/2010.

Wow that's backwards isn't it. Basically comparing NaN != NaN would = true and a Number != NaN would = false. My only conclusion here is that maybe because NaN isn't a comparable entity that saying (NonComparable != NonComparable) = true. Somewhat like trying to compare a null in SQL it isn't a valid comparable.

 

Looking at my example above, it's not very transparent either. So a better way would have been for me to further nest the number into a string and test it against 'NaN' like this:

<Year>
   <xsl:choose>
      <xsl:when test="string(number(string($RepairOrder/VehicleYear)) = 'NaN'">
<xsl:value-of select="number(string($RepairOrder/VehicleYear))"/> </xsl:when>
</xsl:choose>
</Year>

Xml, XSLT

Using MKLINK to create a Symbolic Link

10. February 2011

Not the best blog post ever, but it’s been a bit so…

I’m not a command line guru like some developers I meet. My education was all hands on in Visual Studio and not so much in the command line interface world. However as I gain experience I’m learning more and more.

 

With 64 bit systems you might be writing a bat file and you might want to generate your folder in the Program Files (x86). However to help make life easier for your user you could also create a symbolic link to the Program Files as well which is more or less a shortcut to your folder.

In my company we use Marimba to deploy to our shop servers. As stated above I wanted to create a symbolic link to my Program Files. Below is how I did it.

  1. Open Command Prompt (Admin). Start –> type “cmd” in search and hit Ctrl + Shift + Enter and it will open in Administrator mode, or hit Windows + R and type in “Cmd” either way works.
  2. Just to get a quick look at what MKLink. Type “mklink /?” to look at the help info.
  3. My command line looked like this: mklink /D “C:\Program Files\marimba” “C:\Program Files (x86)\marimba”
  4. The command line response was: “symbolic link created for C:\Program Files\marimba <<==>> c:\Program Files (x86)\marimba.”
  5. Browse to my C:\Program Files, and now I see a marimba folder that when I click it, takes me to my real URI location.

C# Development

Scott Hanselman is cool!

23. November 2010

This is a awesome day. It’s not a technical blog, but I just won a Windows 7 Phone. But even cooler is that I got to talk to Scott Hanselman. He’s a pretty cool guy. So I will dedicate my next mash potatoes statue to Scott.

 

Anyway thanks Scott, you made my day!

 

Here is a link to the contest I won. 

http://www.hanselman.com/blog/WINAFREEPhoneWithLikeNOEffortAndAttendTheWindowsPhone7DeveloperLaunch.aspx

 

Fun

Welcome to BlogEngine.NET 2.0

13. November 2010

If you see this post it means that BlogEngine.NET 2.0 is running and the hard part of creating your own blog is done. There is only a few things left to do.

Write Permissions

To be able to log in to the blog and writing posts, you need to enable write permissions on the App_Data folder. If you’re blog is hosted at a hosting provider, you can either log into your account’s admin page or call the support. You need write permissions on the App_Data folder because all posts, comments, and blog attachments are saved as XML files and placed in the App_Data folder. 

If you wish to use a database to to store your blog data, we still encourage you to enable this write access for an images you may wish to store for your blog posts.  If you are interested in using Microsoft SQL Server, MySQL, SQL CE, or other databases, please see the BlogEngine wiki to get started.

Security

When you've got write permissions to the App_Data folder, you need to change the username and password. Find the sign-in link located either at the bottom or top of the page depending on your current theme and click it. Now enter "admin" in both the username and password fields and click the button. You will now see an admin menu appear. It has a link to the "Users" admin page. From there you can change the username and password.  Passwords are hashed by default so if you lose your password, please see the BlogEngine wiki for information on recovery.

Configuration and Profile

Now that you have your blog secured, take a look through the settings and give your new blog a title.  BlogEngine.NET 1.4 is set up to take full advantage of of many semantic formats and technologies such as FOAF, SIOC and APML. It means that the content stored in your BlogEngine.NET installation will be fully portable and auto-discoverable.  Be sure to fill in your author profile to take better advantage of this.

Themes and Widgets

One last thing to consider is customizing the look of your blog.  We have a few themes available right out of the box including two fully setup to use our new widget framework.  The widget framework allows drop and drag placement on your side bar as well as editing and configuration right in the widget while you are logged in.  Be sure to check out our home page for more theme choices and downloadable widgets to add to your blog.

Try Out New Features

BlogEngine now supports code syntax highlighting and HTML5 video out of the box. To add a video, click the "Insert video" button just above the post editor. Once your video is uploaded, use the following syntax to show it: [­video src="be-sample.mp4"]. Make sure to add "video/mp4" as a MIME type to your IIS.

You can add formatted code by pressing the "Insert Code" button on the post editor toolbar. Here is a small sample:

// Hello1.cs
public class Hello1
{
   public static void Main()
   {
      System.Console.WriteLine("Hello, World!");
   }
}

 

On the web

You can find BlogEngine.NET on the official website. Here you'll find tutorials, documentation, tips and tricks and much more. The ongoing development of BlogEngine.NET can be followed at CodePlex where the daily builds will be published for anyone to download.

Good luck and happy writing.

The BlogEngine.NET team

,

Wcf Tracing

11. November 2010

I was having some issues with Wcf in my input message being SOAP 12 and my Wcf Service accepting SOAP 11, so after I created my custom binding using HttpsTransport. I was still getting a few problems and decided to enable tracing by adding this code to my web.config.

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "c:\logs\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
 

Then I just browse to my .svclog open it up and I an view it in the MS Trace Viewer. Pretty easy, thanks Microsoft.

TechArticle

Using SQLCMD to execute multiple SQL Scripts in folder

9. November 2010

Thanks to Dave Jones for teaching me this who learned this from Sean Heaton. Maybe they will have blogs one day.


 

My company utilizes a midnight installer process that rebuilds a database every night for a {QA, Prod} environment. But sometimes we the developers need to rebuild our databases from these scripts. Previously I would open up the query window. Assemble all the scripts from each file into one file. Copy and paste all the sql scripts details into the query window and execute. Bleh, slow and I hated it. But now if I need to execute a bunch of sql scripts I can do so in a batch file.


 

  1. First I want to open up a “run as” admin command prompt.
  2. Start –> “Search Program and Files”, type in “cmd” this should auto focus on cmd.exe found.

    cmdFind
  3. Then hit “ctrl” + “shift” + “enter” and it will open up a command prompt in administration mode. You can tell because the command prompt will say “Administrator.

    admincmdprompt
  4. Normally I just opened up sql query and copy and pasted the single scripts that run the create database and constraints/foreign key scripts. But now I need to add all the stored procedures. In our company we keep a static database of that product with all of our stored procedures to keep them all in once location. With one table “About” for versioning the set of stored procedures/functions etc. So I will browse to my current TFS workspace location.  In my case: “cd C:\srs_source\Team\Product\Main\Databases\ProductCode\Database\Programmability\Stored Procedures”.
  5. Now I use the command line “dir /b > myFile.cmd” (dir /b list directory with the format I want) and the greater than sign “>” (writes the command output to a file, instead of the command prompt window). http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
  6. Open up “myFile.cmd” in Notepad or I use Notepad++
  7. Remove the “myFile.cmd” from the list
  8. Place cursor on first line and hit “ctrl” + “h” for Replace window prompt.
  9. In Find what type: “\r\n
  10. In Replace with: type: “\r\nsqlcmd –E –n –i” (Update) I now use something like “\r\nsqlcmd -d <databaseName> –E –i” i.e. “\r\nsqlcmd -d Mpi_Data –E –i
  11.   Hit the button “Replace All
  12.   This will replace everything but the first line. At the bottom you will have a empty command “sqlcmd –E –n –I”  just copy this to the first line and you are set to run your batch command.

    sqlReplaceAll
  13.   We are always certain all our sql scripts have the “USE [ProductCode]” for each of our “CREATE PROCEDURES”at the top of each .sql so from this point we can just run it on the command line “myFile.cmd” and it will add these stored procedures to the correct database.

TechArticle

Windows Phone 7 Launch Event

4. October 2010

Windows Phone 7 is coming out soon and I’m very hopeful that it has what it takes to take out Apple’s iPhone lackeys and the Android army and beat all the competition. Google is on my bad list with some of it’s recent transactions and although I like my iPhone, and that could be because I used to work at Apple. I work more in Microsoft tools and I am hopeful that the Windows Phone 7 is going to blow away it’s competitors. 

The launch is going to occur Oct. 11, 2010 and with the awesome “marketing” muscles Microsoft will flex it is going to be a great event.

 

Carriers

So which Carriers are going to host the Windows Phone 7 device? I hope AT&T gets some of the love, but at the press release at the msevent states they will be showing Windows Phone 7 off T-Mobile phones. So we know at least T-Mobile will have it. The question is will it be exclusive. I sure hope not. Only time will tell.

 

To learn more about Windows Phone 7 I’ve provided a convenient link for you to select (Look to the right sidebar icon)

Surround highlighted text with custom strings in Visual Studio 2010

1. September 2010

Oh how lazy I truly is. 

Currently I am doing some heavy manipulation of Xml tags. I ended up with a Excel spreadsheet of new Xml tags I wanted to generate and I wanted to build a Xml document to send off to our QA team for review. MAN was I getting sick of typing "<" and then looking at the text in my excel spreadsheet and typing it in, ensuring I get the case sensitivity correct and then typing ">". At least Visual Studio will generate the closing tag for you. But that was getting very annoying. In comes Macros in Visual Studio. So here is what I did. 

 

  1. Open Macros IDE
    1. Click Tools
    2. Macros
    3. Macros IDE...
  2. Add Module for your Custom Macros
    1. Right click the "MyMacros" in the Project Explorer
    2. Click Add
    3. Add Module
    4. Type in whatever name you want to name this module
    5. Click Add
  3. Program Functions inside your module. 
    1. Public Module CreateXmlTag
    2.     Sub SurroundWithXmlTag()
    3.         DTE.ActiveDocument.Selection.Text = "<" + DTE.ActiveDocument.Selection.Text + ">"
    4.     End Sub
  4. I didn't add the second half of the tags since Visual Studio will auto generate the closing tag. You could do many manipulations here. Like adding <b> for HTML, or whatever you want :)
  5. Save and Close the Macros IDE window
  6. Then I added the macro to a toolbar for convenience
    1. Tools
    2. Customize
    3. Click New
    4. Type in name of Toolbar and click Ok. You will then have a toolbar appear
    5. Click the "Commands" tab
    6. Select the radio button "Toolbar:" (Mine was GenerateXmlTag)
    7. Select "Add Command..."
    8. Under Categories scroll down to "Macros"
    9. Find your Macro
    10. Click Add
  7. Next I wanted to bind it to a keyboard command. 
    1. Select Keyboard...
    2. I filtered by "Xml"
    3. Found my Command 
    4. "Used the new shortcut in:" Xml Editor with Alt+J, Alt+K
  8. Viola!
  9. I can now copy and past my text from Excel

 

OpenDate VoidDate

CloseDate

Highlight and press either my button or my keyboard command and it works like a charm. 

  <OpenDate></OpenDate>
  <VoidDate></VoidDate
  <CloseDate></CloseDate>

P.S. If you don't like the ugly looking text in your toolbar. Visual Studio has a way to add a button image to a command. I personally used Ryan Molden's tool which made things much easier for me. 

http://blogs.msdn.com/b/visualstudio/archive/2010/06/17/command-image-changing-extension.aspx

 

I hoped you enjoyed my lazy post. 

 

 

 

 

 

 

Xml, VS2010, Macros

Name-driven development

25. August 2010

Summary:

Over the last few hours, as tools and technologies continue to evolve, another option has evolved to define a software-solution's architecture: Name-Driven Development (NDD). NDD gives architects the ability to define a solution while creating artifacts that become part of the overall solution. 

 

Overview: 

Often, the inception of a new software solution is an overwhelming task. You have to get approvals from management, high-level requirements etc etc. Taking too much time to analyze a solution can result in lost profits and possible the cancellation of the effort. There are just too many risks involved in giving too little thought to the overall structure of the solution. 

 

Why NDD?

Agile, it is the major engineering movement to move away from requiring full and comprehensive documentation. Thus the argument that you can only truly measure the success of a software project if it makes your company loads of revenue as the optimistic product managers pitched. Therefore no time is spent on documentation and the project can then be declared Agile Magnificent

The Process for Name-Driven Development

Along with a number of non-functioning requirements like unit tests, security, or event management, there is really only one architectural aspect that must be defined for these functional requirements prior to development. These are: 

  1. Name

Defining Name:
Prior to creating any artifacts (code or otherwise), the architect must understand the intent of the solution, and where that solution fits in the context of the business problem that it is solving. Once this requirement is understood. The architect will then understand the basic flow of the business transactions, as if the transactions were to be performed manually.
Once t hese items are understood, the architect then chooses a really neat and cool names for classes and functions that isn't highly overused in the engineering industry. Do not use terms like Class, Object, Data, Collection, Structure, Router, Gateway. Instead use descriptive names such as Keystone, Spring, Ground, Crux, Core, LynchPin, Chief, Driving Force, Nator. 

For Example

Say you had a company that uses a complex key. There are five columns that make the unique identifier to determine the placement of this data. The first is a uid Number, the second, is a group id, the third column is a line type, the fourth, a sub-line type and the last is a price type related to the sub-line type. Knowing this you would make a method named CompanyAKeystone(). Then from that top level method you would create your amazing design. 

Lets analyze the name keystone. A keystone is the architectural piece at the crown of a vault or arch which marks its apex, locking the other pieces into position. This makes the keystone very important structurally.... So knowing that our top level method is the keystone, we then derive the other methods that accomplish this task. You might make a DecipherKey which would be one of your cornerstones. Or a Enum that returns the status of the outcome result after you decipher the key. Maybe it's this type or that type.  The diagram created is easy to understand for any non-technical coworker. Taking our example above, we model this for our wiki documentation about this new feature we are developing. 

Figure 1

 

Conclusion


Name-driven development will increase production of your programmers, the evidence is indisputable. Developers will enjoy utilizing the methodology, thus making them work longer hours for the company to complete the project on time. By creating this example, the solution's architecture was defined, and tangible artifacts were created that can be added to the code base of the solution. If a lot of time had been taken to create a single unit test for this, a steel thread could have been done to prove the architecture sound. Developers would then have a concrete example of how this solution can be expected to behave. 


 

Architecture, Fun ,

Visual Studio Intellisense not working ( ctrl+space)

17. August 2010

My Visual Studio Intellisense was not working. When I was in the Immediate window I was sick and tired of not being able to ctrl + space to get my intellisense. I have Microsoft Messenger Plus! Live installed and apparently they have a preference that overrides the ctrl + space. Here is how you fix it. 

  1. Select Plus!
  2. Preferences and Options...
  3. Click on the "Messenger" tab
  4. Select "Messenger Lock"
  5. Uncheck "Activate Messenger Lock with a system-wide shortcut: or change the hotkey bind.

 

CodeResource ,

Microsoft.WindowsAzure.StorageClient.StorageClientException: One of the request inputs is out of range.

30. April 2010

If you get:
Microsoft.WindowsAzure.StorageClient.StorageClientException: One of the request inputs is out of range.

In my endpoint I labeled my AccountName as "JoshDevStorage" but the AccountName only allows all lowercase letters so after changing it to "joshdevstorage" it worked.

 

:)

ASP.NET, Azure

How to see your Azure Developer Storage using TableXplorer

26. April 2010

As I mentioned previously I have began working with Microsoft Azure's Cloud Solution. One of the tools I found to add to my arsenal for Azure is named TableXplorer which you can download from here: 

http://clumsyleaf.com/products/tablexplorer/

It's a great free tool to use when working with Tables. 

NOTE: For working with BLOBs and Queues you can use WindowsAzure MMC.

http://code.msdn.microsoft.com/windowsazuremmc

Once I downloaded the tool, I wanted to view my dev storage in the provided DeveloperFabric (Which hosts a cloud on your local development box). 

To do so:

1: Open up TableXplorer

2: Select File --> Accounts

3. Select New and enter the following information

      3.1. Name: "devstoreaccount1"

      3.2. Secret Key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

 

 

You should be able to see your devstore storage now. 

Azure

Configuration system failed to initialize

6. April 2010

I am now working to place one of our newest features using Microsoft Azure. When I was attempting to run the "devfabric" which is a simulation of the cloud within your own sandbox. My solution threw me a compile error stating "Configuration system failed to initialize".

 

My Problem:

In my App.config I was using <configSections> but did not have them as the first element under the <configuration> tag. 

Solution:

Once I moved my <configSections> as the first element in my <configuration> tag everything worked. 

C# Development

Add existing folder into Visual Studio (The easy way)

5. March 2010

Ack!

Have you ever selected your folder and said "Exclude from Project" and then if you wanted to add that folder back into your solution, you couldn't. Using "Add existing item" would show you the file dialog and when you select your folder it drills down into that folder. GRR!.

 

 

Well there is a better way: 

In your solution explorer window if you select the icon "Show all Files" 

and then "Right click" your hidden folder and select "Include in Project"

Be certain the folder is in the correct file location within your folder structure to see it.

TechArticle

ASP.NET Paths reference (Content Repost)

1. March 2010

<Taken from Rick Strahl's Web log> at: http://www.west-wind.com/weblog/posts/132081.aspx

ASP.Net includes quite a plethora of properties to retrieve path information about the current request, control and application. There's a ton of information available about paths on the Request object, some of it appearing to overlap and some of it buried several levels down, and it can be confusing to find just the right path that you are looking for.

To keep things straight I thought it a good idea to summarize the path options along with descriptions and example paths. I wrote a post about this a long time ago in 2004 and I find myself frequently going back to that page to quickly figure out which path I’m looking for in processing the current URL. Apparently a lot of people must be doing the same, because the original post is the second most visited even to this date on this blog to the tune of nearly 500 hits per day. So, I decided to update and expand a bit on the original post with a little more information and clarification based on the original comments.

Request Object Paths Available

Here's a list of the Path related properties on the Request object (and the Page object). Assume a path like http://www.west-wind.com/webstore/admin/paths.aspx for the paths below where webstore is the name of the virtual.

Request Property Description and Value
ApplicationPath Returns the web root-relative logical path to the virtual root of this app. 
/webstore/
PhysicalApplicationPath Returns local file system path of the virtual root for this app. 
c:\inetpub\wwwroot\webstore
PhysicalPath Returns the local file system path to the current script or path
c:\inetpub\wwwroot\webstore\admin\paths.aspx
Path 
FilePath 
CurrentExecutionFilePath 
All of these return the full root relative logical path to the script page including path and scriptname. CurrentExcecutionFilePath will return the ‘current’ request path after a Transfer/Execute call while FilePath will always return the original request’s path. 
/webstore/admin/paths.aspx
AppRelativeCurrentExecutionFilePath Returns an ASP.NET root relative virtual path to the script or path for the current request. If in  a Transfer/Execute call the transferred Path is returned. 
~/admin/paths.aspx
PathInfo Returns any extra path following the script name. If no extra path is provided returns the root-relative path (returns text in red below). string.Empty if no PathInfo is available. 
/webstore/admin/paths.aspx/ExtraPathInfo
RawUrl Returns the full root relative relative URL including querystring and extra path as a string. 
/webstore/admin/paths.aspx?sku=wwhelp40
Url Returns a fully qualified URL including querystring and extra path. Note this is a Uri instance rather than string. 
http://www.west-wind.com/webstore/admin/paths.aspx?sku=wwhelp40
UrlReferrer The fully qualified URL of the page that sent the request. This is also aUri instance and this value is null if the page was directly accessed by typing into the address bar or using an HttpClient. Based Referrer client Http header. 
http://www.west-wind.com/webstore/default.aspx?Info
Control.TemplateSourceDirectory Returns the logical path to the folder of the page, master or user control on which it is called. This is useful if you need to know the path only to a Page or control from within the control. For non-file controls this returns the Page path. 
/webstore/admin/

As you can see there’s a ton of information available there for each of the three common path formats:

  • Physical Path 
    is an OS type path that points to a path or file on disk. 
  • Logical Path 
    is a Web path that is relative to the Web server’s root. It includes the virtual plus the application relative path. 
  • ~/ (Root-relative) Path 
    is an ASP.NET specific path that includes ~/ to indicate the virtual root Web path. ASP.NET can convert virtual paths into either logical paths using Control.ResolveUrl(), or physical paths using Server.MapPath(). Root relative paths are useful for specifying portable URLs that don’t rely on relative directory structures and very useful from within control or component code.

You should be able to get any necessary format from ASP.NET from just about any path or script using these mechanisms.

~/ Root Relative Paths and ResolveUrl() and ResolveClientUrl()

ASP.NET supports root-relative virtual path syntax in most of its URL properties in Web Forms. So you can easily specify a root relative path in a control rather than a location relative path:

<asp:Image runat="server" ID="imgHelp"  ImageUrl="~/images/help.gif" />

ASP.NET internally resolves this URL by using ResolveUrl("~/images/help.gif") to arrive at the root-relative URL of /webstore/images/help.gif which uses the Request.ApplicationPath as the basepath to replace the ~. By convention any custom Web controls also should use ResolveUrl() on URL properties to provide the same functionality.

In your own code you can use Page.ResolveUrl() or Control.ResolveUrl() to accomplish the same thing:

string imgPath = this.ResolveUrl("~/images/help.gif");
imgHelp.ImageUrl = imgPath;

Unfortunately ResolveUrl() is limited to WebForm pages, so if you’re in an HttpHandler or Module it’s not available.

ASP.NET Mvc also has it’s own more generic version of ResolveUrl in Url.Decode:

<script src="<%= Url.Content("~/scripts/new.js") %>" type="text/javascript"></script> 

which is part of the UrlHelper class. In ASP.NET MVC the above sort of syntax is actually even more crucial than in WebForms due to the fact that views are not referencing specific pages but rather are often path based which can lead to various variations on how a particular view is referenced.

In a Module or Handler code Control.ResolveUrl() unfortunately is not available which in retrospect seems like an odd design choice – URL resolution really should happen on a Request basis not as part of the Page framework. Luckily you can also rely on the static VirtualPathUtility class:

string path = VirtualPathUtility.ToAbsolute("~/admin/paths.aspx");

VirtualPathUtility also many other quite useful methods for dealing with paths and converting between the various kinds of paths supported. One thing to watch out for is that ToAbsolute() will throw an exception if a query string is provided and doesn’t work on fully qualified URLs. I wrote about this topic with a custom solution that works fully qualified URLs and query strings here (check comments for some interesting discussions too).

Similar to ResolveUrl() is ResolveClientUrl() which creates a fully qualified HTTP path that includes the protocol and domain name. It’s rare that this full resolution is needed but can be useful in some scenarios.

Mapping Virtual Paths to Physical Paths with Server.MapPath()

If you need to map root relative or current folder relative URLs to physical URLs or you can use HttpContext.Current.Server.MapPath(). Inside of a Page you can do the following:

string physicalPath = Server.MapPath("~/scripts/ww.jquery.js"));

 

MapPath is pretty flexible and it understands both ASP.NET style virtual paths as well as plain relative paths, so the following also works.

string physicalPath = Server.MapPath("scripts/silverlight.js");

as well as dot relative syntax:

string physicalPath = Server.MapPath("../scripts/jquery.js");

Once you have the physical path you can perform standard System.IO Path and File operations on the file. Remember with physical paths and IO or copy operations you need to make sure you have permissions to access files and folders based on the Web server user account that is active (NETWORK SERVICE, ASPNET typically).

Server and Host Information

Between these settings you can get all the information you may need to figure out where you are at and to build new Url if necessary. If you need to build a URL completely from scratch you can get access to information about the server you are accessing:

Server Variable Function and Example
SERVER_NAME The of the domain or IP Address 
wwww.west-wind.com or 127.0.0.1
SERVER_PORT The port that the request runs under. 
80
SERVER_PORT_SECURE Determines whether https: was used. 
0 or 1
APPL_MD_PATH ADSI DirectoryServices path to the virtual root directory. Note that LM typically doesn’t work for ADSI access so you should replace that with LOCALHOST or the machine’s NetBios name. 
/LM/W3SVC/1/ROOT/webstore

 

 

Request.Url and Uri Parsing

If you still need more control over the current request URL or  you need to create new URLs from an existing one, the current Request.Url Uri property offers a lot of control. Using the Uri class and UriBuilder makes it easy to retrieve parts of a URL and create new URLs based on existing URL. The UriBuilder class is the preferred way to create URLs – much preferable over creating URIs via string concatenation.

Uri Property Function
Scheme The URL scheme or protocol prefix. 
http or https
Port The port if specifically specified.
DnsSafeHost The domain name or local host NetBios machine name 
www.west-wind.com or rasnote
LocalPath The full path of the URL including script name and extra PathInfo. 
/webstore/admin/paths.aspx
Query The query string if any 
?id=1

The Uri class itself is great for retrieving Uri parts, but most of the properties are read only if you need to modify a URL in order to change it you can use the UriBuilder class to load up an existing URL and modify it to create a new one.

Here are a few common operations I’ve needed to do to get specific URLs:

Convert the Request URL to an SSL/HTTPS link

For example to take the current request URL and converted  it to a secure URL can be done like this:

UriBuilder build = new UriBuilder(Request.Url);
build.Scheme = "https";
build.Port = -1;  // don't inject port

Uri newUri = build.Uri;
string newUrl = build.ToString();

Retrieve the fully qualified URL without a QueryString 
AFAIK, there’s no native routine to retrieve the current request URL without the query string. It’s easy to do with UriBuilder however:

UriBuilder builder = newUriBuilder(Request.Url); 
builder.Query = ""
stringlogicalPathWithoutQuery = builder.ToString();

What else?

I took a look through the old post’s comments and addressed as many of the questions and comments that came up in there. With a few small and silly exceptions this update post handles most of these.

But I’m sure there are a more things that go in here. What else would be useful to put onto this post so it serves as a nice all in one place to go for path references? If you think of something leave a comment and I’ll try to update the post with it in the future.

ASP.NET

Useful properties (content repost)

1. March 2010

As a resource for myself I found this blog entry and wanted to retain the information as a reference list. Thanks to SheoNarayan for this post. Which you can find here: http://www.dotnetfunda.com/articles/article79.aspx

 

Reposting in case that site dies:

System.Web.HttpRequest (Request) object is used to get the information about the user. In this article, I am trying to show some useful properties of Request object that is very handy and useful while developing ASP.NET applications.

I have presented this information by taking example of a url http://localhost/myfunda/test.aspx?q=search&re=afdsf where "localhost" is my local IIS, "myfunda" is a virtual directory name and "test.aspx" page is the name of the page where the request object property has been written.

Follwing example has been show in the format of

Request Object: Result - Description

Request object

Request.Path: /myfunda/test.aspx - Is used to get information about the path of the url from where the request is being made.

Request.Cookies: - Get the collection of cookies, To know more about cookie, refer to http://www.dotnetfunda.com/articles/article61.aspx

Request.ContentLength: 0 - Returns the length of content sent by the browser.

Request.IsLocal: True - Returns the value indicating whether the request is from local computer.

Request.IsSecureConnection: False - Returns the value indicating whether the connection is secure (using HTTPS).

Request.PhysicalApplicationPath: C:\Web\MyFunda.Web\ - Returns physical application path.

Request.PhysicalPath: C:\Web\MyFunda.Web\test.aspx - Returns physical path of the file being requested.

Request.QueryString: q=search&re=afdsf - Returns all querystrings excluding ?. 

Request.RawUrl: /myfunda/test.aspx?q=search&re=afdsf - Returns the url (including the virtual directory if any) of the page along with querystring.

Request.UserHostAddress: 60.243.141.170 - Returns the ip address of remote client.

Request.UserHostName: 60.243.141.170 - Returns the host name (DNS Name) if specified or returns the ip address of the remote client.

Request.ApplicationPath: /myfunda - Returns the virtual application root path.

Request.Url: http://localhost/myfunda/test.aspx?q=search&re=afdsf - Returns the complete url of the current request as appears in web browser address bar.

Request.Url object

Request.Url.AbsolutePath: /myfunda/test.aspx - Returns the absolute path (no querystrings)

Request.Url.AbsoluteUri: http://localhost/myfunda/test.aspx?q=search&re=afdsf - Returns the absolute URI, almost same as Request.Url.

Request.Url.Authority: localhost - Returns the IP Host name or IP Address of the server.

Request.Url.Host: localhost - Returns the host of this instance. 

Request.Url.HostNameType: Dns - Gets the type of the host specified in the uri.

Request.Url.IsDefaultPort: True - Gets whether the port value for the URI is default.

Request.Url.IsFile: False - Gets information whether the specified uri is the file uri.

Request.Url.LocalPath: /myfunda/test.aspx - Gets local file path name

Request.Url.OriginalString: http://localhost:80/myfunda/test.aspx?q=search&re=afdsf - Returns original uri passed to the uri constructor.

Request.Url.PathAndQuery: /myfunda/test.aspx?q=search&re=afdsf - Returns the path and querystring of the uri.

Request.Url.Port: 80 - Gets the port number of the uri.

Request.Url.Query: ?q=search&re=afdsf - Gets the querystring of the uri along with ?

Request.Browser object

Request.Browser.BackgroundSounds: True - To know whether browser supports background sound.

Request.Browser.Beta: False - To know whether current version is in Beta release.

Request.Browser.Browser: AppleMAC-Safari - Get the browser string (if any).

Request.Browser.CanInitiateVoiceCall: False - Get a value indicating whether browser can initiate voice call.

Request.Browser.CanSendMail: True - Get a value indicating whether browser can send email using mailto: .

Request.Browser.Cookies: True - Get a value indicating whether the browser supports cookie.

Request.Browser.Crawler: False - Get a value indicating whether the browser is a search engine web crawler.

Request.Browser.DefaultSubmitButtonLimit: 1 - Get the maximum number of submit button allowed in a form.

Request.Browser.Frames: True - Get a value whether browser supports Frames.

Request.Browser.HasBackButton: True - Get a value whether browser has a dedicated back button.

Request.Browser.Id: safari1plus - Get the internal identifier of the browser as specified in tbe browser definition file.

Request.Browser.InputType: keyboard - Returns the type of input supported by the browser.

Request.Browser.IsColor: True - Get a value indicating whether the browser has a color display.

Request.Browser.IsMobileDevice: False - Get a value indicating whether the browser is a mobile device (if recognized).

Request.Browser.JavaApplets: True - Get a value indicating whether the browser supports Java applets.

Request.Browser.JavaScript: True - Get a value indicating whether the browser supports JavaScript.

Request.Browser.EcmaScriptVersion: 1.4 - Get the version number of Ecma script supported by browser.

Request.Browser.JScriptVersion: 0.0 - Get the version of the JScript supported by the browser.

Request.Browser.MajorVersion: 5 - Get the major version of the browser.

Request.Browser.MinorVersion: 0 - Get the minor version of the browser.

Request.Browser.MaximumHrefLength: 10000 - Get maximum number of characters supported for href (hrml link) element 

Request.Browser.MaximumRenderedPageSize: 20000 - Get maximum length of the page in byte browser can display.

Request.Browser.MaximumSoftkeyLabelLength: 5 - Get maximum length of the text that a soft key label can display.

Request.Browser.MobileDeviceManufacturer: Unknown - Get the name of the mobile device manufacturer, if identifiable.

Request.Browser.MobileDeviceModel: Unknown - Get the name of the model number of mobile device , if identifiable.

Request.Browser.Platform: WinXP - Get the name of the platform client is using.

Request.Browser.PreferredRenderingType: html32 - Get the name of the type of content browser prefer to get.

Request.Browser.ScreenBitDepth: 24 - Get the depth of the display, a bits per pixel.

Request.Browser.ScreenCharactersHeight: 40 - Returns the approximate height of the display in lines.

Request.Browser.ScreenCharactersWidth: 80 - Returns the approximate width of the display in characters.

Request.Browser.ScreenPixelsHeight: 480 - Returns the approximate height of the screen in pixel.

Request.Browser.ScreenPixelsWidth: 640 - Returns the approximate width of the screen in pixel.

Request.Browser.SupportsBold: True - Gets a value indicating whether browser supports <b> html element.

Request.Browser.SupportsCacheControlMetaTag: True - Gets a value indicating whether browser supports cache control value in the META element.

Request.Browser.SupportsCss: True - Gets a value indicating whether browser supports CSS.

Request.Browser.SupportsDivAlign: True - Gets a value indicating whether browser supports align attribute of the <div> html element.

Request.Browser.SupportsEmptyStringInCookieValue: True - Gets a value indicating whether browser supports null in cookie values.

Request.Browser.SupportsFontColor: True - Gets a value indicating whether browser supports color attribute in <font> html element. In the same way, we have for font size, font name etc.

Request.Browser.SupportsImageSubmit: True - Gets a value indicating whether browser supports submission of form using a custom image in place of a button.

Request.Browser.SupportsQueryStringInFormAction: True - Gets a value indicating whether browser supports querystring in the action attribute of the <form> html element.

Request.Browser.SupportsSelectMultiple: True - Gets a value indicating whether browser supports multiple selection in the <select> html element.

Request.Browser.SupportsXmlHttp: False - Gets a value indicating whether browser supports receiving xml over HTTP.

Request.Browser.Tables: True - Gets a value indicating whether browser supports receiving <table> html element.

Request.Browser.Type: Desktop - Can be used to Get name and major version of the browser.

Request.Browser.VBScript: False - Gets the value whether browser supports VBScript .

Request.Browser.Version: 5.0 - Gets the full version of the browser.

Request.Browser.Win32: True - Gets the value indicating whether the client is using Win32 based system.

There of course many more properties than I have conver in this article, however I felt these are most frequently used and useful to know. Thanks for reading and please add other useful information related to Request if you have by responding to this article.

 

ASP.NET

SQL native HierarchyID

23. October 2009

Okay quick blog for today. Not my best, but I have been working with SQL's native HierarchyID type and didn't want to see the regular Hex of 0X5B6EAD6B, So by adding a simple .ToString() on my Select statement for my table I was able to change it to be "/1/2/13/"

 

SELECT TOP 1000 [WidgetInstanceID]

      ,[ParentWidgetInstanceID]

      ,[WidgetTemplateID]

      ,[WidgetInstanceHierarchyID].ToString() as WidgetHiearchyID

  FROM [SrsWebPlatform].[dbo].[WidgetInstance]

 

Which gave me my results of:

WidgetInstanceID ParentWidgetInstanceID WidgetTemplateID WidgetHiearchyID WidgetInstanceLevel

1001                          1022                          1026                     /1/2/13/                      3

 

If you don't know about the HiearchyID in SQL Server 2008 you can read more about it here: 

http://www.sqlservercentral.com/articles/SQL+Server+2008/62204/

 

Off to go SCUBA dive this weekend. Take care!

The base class includes the field ‘MyUserControl_1, but its type (MyUserControl) is not compatible with the type of control (ASP.MyControl_ascx).

1. October 2009

Have you received this error?

 

The base class includes the field ‘MyUserControl_1, but its type (MyUserControl) is not compatible with the type of control (ASP.MyControl_ascx).

 

Or in my case:

 

The base class includes the field 'proxyContainer', but its type (ProxyContainer) is not compatible with the type of control (ASP.maintenance_proxycontainer_ascx).

 

Well first you should check out this article and see if it fixes your problem:

 

http://support.microsoft.com/kb/919284

 

 

However for some of you (myself included) that article didn’t do squat to fix my problem with the error listed above, I don’t want to keep my control in the same folder as my pages.

 

Based on the article above I fall under the category of: “The application contains references to Web pages that are outside the current directory.

 

My Design:

My code uses a "ProxyContainer.ascx" UserControl that references another user control on another server in another assembly. I register the control on a page and one of my properties is to point to the HostServerURL and ControllerInstanceId. 

Everytime I changed anything at all the code threw me the above said error. (Even when it was just a char on the HTML page). 

Problem:
In the ASPX Page I was referencing my ProxyContainer.ascx everytime I made any changes at all the auto generated  designer code was changing my type from


protected global::System.Web.UI.UserControl proxyContainerControl;

to 

protected global::ProxyContainer proxyContainerControl;


Which then caused my circular reference.

 

Solution:

I need to stop the auto-generated code from changing my type and I’m set. I moved the code:

 

“protected global::ProxyContainer proxyContainerControl;”

 

 Into the code behind at the class level fields and the designer stopped generating my type and now it all works.

 

Solution #2:

 

I was helping somebody on Expert Exchange and their problem was to Change their Codebehind to a CodeFile in the ASCX file.

ASP.NET

Cannot resolve symbol ‘’ error in Visual Studio 2008

9. September 2009

Today I copied over another user control from another project into my current project and the code behind page was giving me an error on the label on the page. The error was :  “Cannot resolve symbol ‘ ’:

After a little investigation I found this is being thrown by my ReSharper Plug-in and the recommended solution was for me to disabled ReSharper and try the build again.

To disable ReSharper I did the following:

1)      Click “Tools”

2)      Select “Add-in Manger …”

            

3)      Then uncheck the ReSharper Plug in and select “OK”

 

 

I built the project and guess what? I got another error. This one read as follows:

The name ‘ ’ Does Not Exist in the Current Context

 

Doh! Okay so here is my real error after peeling back the onion layer of the ReSharper app. I needed to change the way the code behind was building for it to reload the memory. So here is what I believe is occurring.

 

My Visual Studio Website is setup to Use IIS Web Server (Project Properties à Web à Use IIS Web Server)

 

I believe that once the assembly (.dll) has been loaded into IIS memory it is then marked as “in use” and now only IIS can unload or load a fresh copy. When Visual Studio attempts to replace the assembly with a debug build it cannot do so.

 

To get around this problem I opened the properties (F4) of my code behind (.cs) page and changed the Build Action to be Embedded Resource

 

 

 

I compiled and it fixed my problems. Of course you could just try changing the Build Action and not disabled ReSharper, but I wanted to list every step I took to resolve my programming issues.

Below is a list of each Build Action description in case you were interested in the other types of builds such as I was.

·         None:

o   Umm should be obvious

·         Compile

o    Linker and Library compile solution

·         Content

o   Allows you to retrieve a file (in same dir as assembly) as a stream via Application.GetContentStream ( uri ).  For this to work, you need AssemblyAssociatedContentFile custom attribute which visual studio adds when you mark a file as “Custom”

·         Embedded Resource

o   Embeds the file in an exclusive assembly manifest resource

·         CodeAnalysisDictionary

o   This is used when you want to add a custom dictionary to your project. Create new xml file, select Build Action to be CodeAnalysisDictionary and you are now ready to start using your custom dictionary.

·         ApplicationDefinition:

o   Mark the XAML/Class file that defines your application. You specify the codebehind with the x:Class=”Namespace.ClassName” and set the startup form/page with StartupUri=”Window1.xaml”

·         Page:

o   Identifies a XAML markup file whose content is converted to a binary format and compiled into an assembly. Page items are typically implemented in conjunction with a code-behind class

·         Resource

o   Identifies a resource file that is compiled into an application assembly.

·         SplashScreen

o   Allows a developer to add a splash screen “bitmap” to WPF applications. This option is set to show the splash screen dynamically.

·         EntityDeploy

o   This is used by the EntityFramework, but not very useful in Silverlight.

When completed I re-enabled everything "ReSharper" and set my cs file back to "Compile" and everything is working perfectly.

ASP.NET