Welcome to MSDN Blogs Sign in | Join | Help

Fewer smaller .Net DLLs vs less large DLLs

Generally speaking it is better to have less large DLLs versus many smaller DLLs for the following reasons:

  • Hard Disk time:  Loading 100 dlls will almost always take longer than a single large DLL.   DLLs are physically scattered across the disk.  Latency etc come into play on the initial load times.
  • Memory Usage: A single dll contains 1 set of "standard" meta data vs 100 times that standard meta data can start to make up some memory space (i.e. X bytes of product name, version info, etc x 100 dlls x # of app domains = memory)
  • Security: .Net CLR has to do a lot more processing with multiple DLLs vs less DLLs.  A security policy will need to be loaded, managed, and executed per each DLL.
  • CLR Management:  If DLLs do not specifically call for a unique "base address" so the CLR must re-base each DLL when it loads them costing startup cycle time.  Also when code executes the CLR must locate the object in memory and if it has to go through a "lookup table" of those addresses it will take longer to find one if multiple DLLs are used.
  • Management: Locating code, determining DLL references to use, build scripts, etc will take more time to manage in the SDLC.
  • Optimization: The .Net compiler can make more and better optimization decisions if acting on more code base.   Smaller sets of code will provide less optimization opportunities.
  • Maintenance: Managing the additional project files, assembly info files, etc add time and understanding to developers.

Additional information: http://blogs.msdn.com/brada/archive/2004/05/05/126934.aspx

Visual Studio and .Net Tutorials and Training Videos

A friend asked about some sites to learn about Visual Studio and programming.   There is a lot of great free resources out there.   I created an article with a starting list to help.  Feel free to comment and suggest the "best" free sites out there.

Visual Studio and .Net Tutorials and Training Videos

Posted by mab | 0 Comments
Filed under:

Steps to add Developer Tools to Send To folder

Steps to add programs to Send to folder

  1. Navigate to your SendTo folder (Windows XP location is C:\Documents and Settings\{user}\SendTo and just replace {user} with your login user name)
  2. Right click select New/Shortcut to add a shortcut
  3. Type in the location of the program to send the file to then click Next
    1. Notepad is “%windir%\notepad.exe”
    2. Visual Studio 2008 is "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /edit
  4. Give the send to a name that is user friendly (i.e. Notepad or Visual Studio 2008 as appropriate)

 

TFS Extras Article Created

Started a article that will contain lots of free/commerical add-ons and website articles for TFS.  

Enjoy the first edition: http://blogs.msdn.com/mab/pages/team-foundation-server-extras.aspx

Free Telerik TFS Manager and Dashboard

As a Microsoft VSTS ranger, I come across some interesting TFS add-ons on occasion.   The recently introduced Free Telerik TFS Manager and Dashboard tool seems impressive.  Most of the features enhance SCRUM/Agile methodology shops but can be used for any methodology.

Main Page
http://www.telerik.com/products/tfsmanager-and-tfsdashboard/tfs-work-item-manager-features.aspx

Features

  • Work Item grid filtering, grouping, and aggregation
  • Area and Iteration filtering using single and multi select modes
  • Filter query results using a tree of areas or iterations
  • Unique Task board view of work items independent from any process template
  • Print work item cards for the board in your room
  • Iteration schedule
  • Paste as New/Current work item
  • "New by example" saves your query for other team members
  • Search the title and description of query results as you type

How to close window (self) without prompting in IE6 and IE7

Scenario
Web application wants to pop-up a window as a certain size, chromeless, etc.  However doesn't want to have the opening (parent) window show.  Common usages are launching from shortcut or an application.

Solution
In the "parent" page that launches the popup.   Put the following code to close your(self) in javascript: 

var self2 = window.open("", "_self");
self2.focus();
self2.opener = self2;
self2.close();

Posted by mab | 0 Comments
Filed under:

How to autoresize parent frame height from child frame

Scenario
A parent document contains a frame that loads a file which content is dynamic and you want the frame to not scroll and autosize the height of the frame.

Solution
function autoResizeParent() {

// if no parent don't attempt to change
if (parent != null) {

var frameList = parent.document.body.getElementsByTagName("iframe");

// is there any frames?

if (frameList != null) {

for (var i = 0; i < frameList.length; i++) {

var srcName = frameList[i].src;

srcName = srcName.substr(srcName.lastIndexOf("/"));

var srcParent = document.location.pathname.substr(document.location.pathname.lastIndexOf("/"));

alert("Parent=" + srcParent + "\nFrame="+ srcName);

// found myself

if (srcParent == srcName) {

// set parent frame height to my height

frameList[i].height = document.body.offsetHeight;

// force scrolling off

frameList[i].scrolling = "no";

}

}

}

}

}

Posted by mab | 0 Comments

How to access SQL Server on Windows through a secure connection from Perl on Linux

Scenario

Have some perl code that wants to access Microsoft SQL Server 2005.   The SQL Server is configured to only allow SSL connections for security reasons.

Solution 

Here are the parts you will need:

Resources

Microsoft guidance on accessing SQL Server with Perl
http://technet.microsoft.com/en-us/library/bb497071.aspx 

Thanks for Brian on helping figure this out :) ... I am just the messenger.

Posted by mab | 0 Comments
Filed under: ,

Windows 2008 R2 Hyper-V and Remote Desktop

Scenario

Download your favorite image (or create one) and you want to exchange files with the guest OS.   You are running Wi-fi and have to use the wired connection as your virtual network.   You can access your image just fine through the Hyper-V Virtual Machine connection app but it doesn't support accessing host folders.

Solution 

Remote Desktop to the rescue!   Yes I know, this is old news, but read on for the problem you may encounter.  

Problem

You start up remote desktop and try to access via IP and/or host name and you get that it is not there.   Hmmm....

Real Solution

The problem may be that by default Remote Desktop will try to auto-detect a remote desktop gateway.   When you are connected to the internet or you LAN you may encounter one!    Just go over to the options/Advanced and choose to NOT use a gateway and voila! it works!

Now you can change your settings to share local host drives with your remote session (your guest VM) and start sharing!

Posted by mab | 2 Comments

How to recycle a IIS6 website in Windows Server 2003 SP1

Many clients I have worked with simply use the IISReset.exe command to recycle applications.  Although this may have the desired affect sometimes, there are many alternatives that are better. By no means is this an exhaustive list but will give you some options when a specific website is causing problems (i.e. hung, OOM).   Stopping a website doesn't reset memory or the worker process it just stops the website from processing the requests.   Therefore, the website "start/stop" actions are not listed below.

Single Web Application "resets"

  1. Recommended: Recycle the application pool of the specific website's application pool.  With Windows Server 2003 SP1 the command line is iisapp.vbs:  Reference: http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx.  You can use a process id /p or an application id with /a. 

    Examples:
    D:\WINDOWS>iisapp /p 596 /r 
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    Application pool 'DefaultAppPool' recycled successfully.

    D:\WINDOWS>iisapp /a DefaultAppPool /r
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    Application pool 'DefaultAppPool' recycled successfully.
Reseting ALL websites on a server (not recommended)
  1. Start and stop specific services for web services only (do not do the start commands if you are not recycling)
    NET STOP W3SVC
    NET STOP HTTPFilter (if having problems with SSL)
    NET START HTTPFilter (if having problems with SSL)
    NET START W3SVC
  2. Use IISReset /NOFORCE , this causes the system to not forceable terminate the internet services if timeout or error occurs.  Note: this will reset all IIS services that are enabled: FTP, NNTP, WWW, IISAdmin, etc.
  3. IISReset (without /NOFORCE) causes a forceable stop if doesn't respond within 60s (the stop default can be changed via command line).  This may lead to IIS configuration loss (http://support.microsoft.com/kb/286196). Note: this will reset all IIS services that are enabled: FTP, NNTP, WWW, IISAdmin, etc.
  4. Reboot the server.  Not recommended and may cause signficant data loss.  Note: this attempts to shutdown or forcably shutdown all applications on the server not just IIS related.
  5. Power cycle the server.  Not recommended and may cause signficant data loss.  Note: this is extremely dangerous and only to be used when all other options (even one's not listed above) have been tried.

 Hope this helps ...

Posted by mab | 1 Comments
Filed under: ,

Install a remote printer via a Hyperlink in HTML

Ever tried to install a printer by just giving users a link?  Well here is a small snippet of one way to do this.   Please note that since you are interacting with the OS (outside the browser) that you may receive security warnings.   This has been tested on Vista SP1 x86 32 bit with IE7.

Code

<html>
<head>
<script type="text/vbscript">
function AddP(pName)
msgbox "Start"
Set WshNetwork = CreateObject("Wscript.Network")
WshNetwork.AddWindowsPrinterConnection pName
msgbox "Finished"
end function
</script>
</head>
<body>
<a href='#' language="vbscript" onclick="AddP('\\Home-PC\HP Photosmart 3300 series')">Add printer</a>
</body>
</html>

 Please note that above the a href should be ="#" not single quotes.

Posted by mab | 2 Comments

Using Visual Studio with IIS7 on Vista and Win 7

For those interested in installing VSTS and using with IIS7 on Vista (and possible with Win 7) you should follow the following instructions:

http://msdn.microsoft.com/en-us/library/aa964620.aspx

Posted by mab | 1 Comments
Filed under:

How to do logic OR AND NOT across rows in SQL

Scenario

You have a normalized table that has values in rows.   Let's take an example that has a history table with an approved flag:

 Date  Approved  DollarValue  Customer
1/1/2008  Y    13.5    A
2/1/2008  N    12      A
3/1/2008  Y    14      A

1/1/2008  Y    11.5    B
2/1/2008  Y    9        B
3/1/2008  Y    17      B

1/1/2008  Y    13.5    C
2/1/2008  Y    29        C
3/1/2008  Y    18      C 

You want to find know if all the customers with all 3 monthly values approved and the values are < 20.    Now I know you can get at this result multiple ways but I just want to show how you can apply logic across rows.

First you know that there are 3 monthly records for all the months data and you are also looking for an approved.

SELECT DISTINCT Customer
FROM MyTable
WHERE Approved = 'Y' AND DollarValue < 20
GROUP BY Customer
HAVING COUNT(Customer) = 3

You should see an output with only Customer B.

Similar techniques can be applied for OR and NOT.

Posted by mab | 0 Comments
Filed under:

Custom Security and SQL Job with SSIS Script Task

Scenario

Recently I ran into a security issue that has a simple fix.  Here is the situation:

  • SSIS Package that contains a Script Task
  • Run SSIS package as a SQL Job
  • Use a special credential/proxy for the step of executing the SSIS package

Results

In the SQL Job History Log you may find something like this ...
Code: 0x00000002     Source: XXXXX Script Task      Description: The script threw an exception: Unable to generate a temporary class (result=1).  error CS2001: Source file 'C:\WINDOWS\TEMP\yyyzzzxxx.N.cs' could not be found  error CS2008: No inputs specified

Solution

Simple put,the VBA compiler has permissions to write the file into C:\windows\temp but your credential does not.   Now the simple fix is to allow just read/read&execute/list permissions to C:\windows\temp and that will resolve the issue above.   However, please not that there is a potential security risk in doing so as that this credential now has access to read all temp files in this directory.   So be forewarned that this may not fit your situation.

Conclusion

Although not suggesting the ideal security solution, this may help you troubleshoot and further refine your strategy in running you SSIS package with a Script task with a custom credential/proxy.

 

Posted by mab | 1 Comments
Filed under:

Optimizing queries with joins and over statements in SQL 2005

I was working on a common scenario and found an interesting side effect. Applications typically have a listing page that get search criteria from a UI and passes to a stored procedure. In the procedure you often find statements like:

SELECT a,b,c,d
FROM MyTable
WHERE c = @SearchC AND d = @SearchD

Often times you need to join information to the main data that is the most current from a historical table. For example in SQL 2005.

SELECT t.*
FROM
(SELECT
ID
, Amt
, AmtDepositDate
, row_number() over (partition by ID order by ID, AmtDepositDate desc) as rn
FROM MoneyTable
) t
WHERE rn=1

I found that when you join the above query to the main search query above a weird optimization occurs in SQL 2005. I suspect (unconfirmed with product group) that a left join can't optmize the query with the over so it ends up do a sub select on all records every row in the main search.

The solution (in my case where there is small sets of data of < 5000 records), I create a table variable and select into the lasted record from the history table. Then I join the table variable to the main table search.

In my scenario with 2000 main records and 1 million history records the left join with the latest select (no table variable) took 5+ minutes. Using the table variables took 2 seconds for everything.

Here is a snippet of the overall solution:

DECLARE @MyTable table (
      ID int
      ,Amt float
      ,AmtDepositDate datetime
      )

INSERT INTO @MyTable
SELECT
      t.ID
     
,t.Amt
     
, t.AmtDepositDate
FROM
      (
      SELECT
      ID
     
, Amt
     
, AmtDepositDate
     
, row_number() over (partition by ID order by ID, AmtDepositDate desc) as rn
     
FROM MoneyTable
     
) t
WHERE rn=1

SELECT
      MT2
.ID
     
, MT2.Name
     
, MT2.City
FROM
      MyTable2 MT2
LEFT JOIN @MyTable MT
     
ON MT2.ID = MT.ID
WHERE
      c
= @SearchC AND d = @SearchD

Anyone experience similar or can offer up an reason for the optimization?

 

Posted by mab | 1 Comments
Filed under:
More Posts Next page »
 
Page view tracker