Asp.net, listbox, htc, behavior, autosearch listbox
Welcome to MSDN Blogs Sign in | Join | Help

Override Default Xml Serialization

This is some hidden fact about xml serializers in .Net.

 There is an option is to use a special pattern to create a Boolean field recognized by the XmlSerializer, and to apply the XmlIgnoreAttribute to the field. The pattern is created in the form of propertyNameSpecified. For example, if there is a field named "MyFirstName" you would also create a field named "MyFirstNameSpecified" that instructs the XmlSerializer whether to generate the XML element named "MyFirstName". This is shown in the following example.

C#
 
public class OptionalOrder
{
    // This field should not be serialized 
    // if it is uninitialized.
    public string FirstOrder;

    // Use the XmlIgnoreAttribute to ignore the 
    // special field named "FirstOrderSpecified".
    [System.Xml.Serialization.XmlIgnoreAttribute]
    public bool FirstOrderSpecified;
}
Posted by Sundara Prabu .T | 0 Comments
Filed under:

WCF .NET 4.0 RoadMap

 

.NET 4.0 brings several improvements in the areas of WCF and WF, including improved REST capabilities, a new workflow model, seamless integration between WF and WCF, and a new visual designer. It also provides the ability to author completely declarative (XAML-based) workflow services that can be more easily deployed, hosted, and managed

 

WCF Features

 

Simplified Configuration – Implicit Endpoints, Default Endpoint & Binding Configurations

Discovery - based on contracts

Routing- xpath based content Routing.

Improved REST support

BLOB Encoder

 

 

A Developer's Introduction to Windows Communication Foundation (WCF) .NET 4 Beta 2
An overview of the most important new features and improvements in WCF, with enough technical detail and code to help you as a developer understand how to use them. Now updated for Beta 2.

 

Windows Communication Foundation (WCF) Samples for .NET Framework 4.0 Beta 2
This package contains samples for exploring the new features in Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) for .NET Framework 4.0 Beta 2.

 

Introducing Windows Server AppFabric
On Nov 17th 2009 at the Professional Developers Conference (PDC) Microsoft announced the release of Windows Server AppFabric beta1. AppFabric evolves the existing application server capabilities of Windows Server to make it easier to build, scale and manage ASP.NET and WCF and WF applications that run on Internet Information Services (IIS).

 

Videos :

 

What's new in WF/WCF 4.0

 

endpoint.tv - Service Discovery with WCF
WCF in .NET 4 includes an implementation of the WS-Discovery protocol.

Posted by Sundara Prabu .T | 0 Comments
Filed under: ,

Find all references, go to definition do not work across VB/C# projects in same solution

While using Visual Studio today I noticed an anomaly. When I bring up a file in VS2008 Solution Explorer AuditEventPublisher.vb in MyVbProject.vbproj

Scroll down to the Publish method, right click and select “find all references”, Visual Studio does not report on the instances in which the method is used in the namespace MyCSharpProject.csproj. MyCSharpProject has a Project reference to MyVbProject and both are in the same solution.

 

I tried a number of things and did some research – but could not get it to work or find an explanation. Also, when I bring up this class in the IDE ClientAuditMessageInspector.cs in MyCSharpProject.csproj and right click on the AuditEventPublisher.Publish() method and select “go to definition” – it brings up a metadata class instead of the actual code.

 

The only theory I have is that the fact that one project is in VB and the other in C# in the same solution - is this the cause. ?

 

This is a known bug / limitation in VS 2008 SP1 . The same thing happens in Vs2010 Beta 2 as well.

 

Reason from Product Team:

 

This issue is by design given our current architecture and has always existed in the product.   The reason this occurs is because a different compiler is used for each type of project (the C# one for C# projects and the VB one for VB projects) and they each populate a separate symbol table.  This symbol table is not shared in a live way across the two types of projects – symbol sharing occurs once an assembly has been flushed to disk.

The project-to-project reference between a C# and VB project is treated like a file assembly reference where all symbols are treated as if coming from metadata.

link here..

http://blogs.msdn.com/technet/pages/find-all-references-go-to-definition-do-not-work-across-vb-c-projects-in-same-solution.aspx

 

Posted by Sundara Prabu .T | 0 Comments
Filed under:

Linq Select Distinct Records based on a field or Property

Have a look at  the sample below, Is there a simpler way of achieving this ? 

 

I needed the results

1 vp

2 x

3 y

 

Rest should be ignored

public class customer

        {

            public int id;

            public string name;

 

 

            public static IEnumerable<customer> getDistinct()

            {

                List<customer> cust = new List<customer>();

 

 

                cust.Add(new customer() { id = 1, name = "vp" });

                cust.Add(new customer() { id = 2, name = "x" });

                cust.Add(new customer() { id = 3, name = "y" });

                cust.Add(new customer() { id = 1, name = "vp" });

                cust.Add(new customer() { id = 1, name = "vfp" });

                cust.Add(new customer() { id = 1, name = "vp" });

                cust.Add(new customer() { id = 1, name = "vpd" });

                cust.Add(new customer() { id = 1, name = "vsp" });

                cust.Add(new customer() { id = 1, name = "vfrp" });

                IEnumerable<customer> newcust = cust.Distinct<customer>(new xcomp()) ;

             

                return newcust;

            }

            public class xcomp : IEqualityComparer<customer >

            {

                #region IEqualityComparer<customer> Members

 

                bool IEqualityComparer<customer>.Equals(customer x, customer y)

                {

                    return x.id == y.id;

                }

 

                int IEqualityComparer<customer>.GetHashCode(customer obj)

                {

                    return obj.id.GetHashCode();

                }

 

                #endregion

            }

        }

 

Posted by Sundara Prabu .T | 0 Comments
Filed under: ,

asp.net 3.5 checkboxlist AddAttributesToRender Not called in Override

I recently came across this issue where in if we override the AddAttributesToRender method in our custom CheckBoxlist.

It never gets called at all.

Instead we had to use PreRender or RenderItem refer

http://www.dotnetmonster.com/Uwe/Forum.aspx/asp-net-controls-building/3261/checkboxlist-AddAttributesToRender

Is any one aware of a Msdn link confirming the same.

VSTS Tester Edition : Webtest with Code Coverage Error :No connection could be made because the target machine actively refused it 127.0.0.1:80

VSTS Tester Edition 2008 :

When i ran a Webtest with Code Coverage

I got this Error :No connection could be made because the target machine actively refused it 127.0.0.1:80. I found that IIS was stopped. Started It.

Then I found that my Web.config had a additional <location> tag, after bringing it back to the previous state (I did a undo checkout).

Then It gave an error that it was not able to access the web.config (It was Checked in to TFS).

So i just did a checkout of the web.config and reran the webtest with code coverage enabled.

Wow now it runs successfully and at the end shows the codecoverage results as well.

Get Public Key Token from Snk File using Msbuild

I have written a small msbuild script which can be used to get the public key and the public key token from the .snk file.

This attachment needs to be executed from the visual studio command prompt . Update the WorkingDir and SnkFilePath as needed, after downloading  the attachment.

Run it as msbuild <file name>. the output token is in Onlytoken.txt.

The output public key is in OnlyPublic.snk.

Here is the snippet of the same script.

<Project DefaultTargets="GetPublicKey" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>

<WorkingDir>D:\Work\</WorkingDir>

<HighLevelErrFile>ErrLog.log</HighLevelErrFile>

<SnkFilePath>StrongNameKey.Snk</SnkFilePath>

</PropertyGroup>

<!--TFS Get Latest Configs-->

<Target Name="GetPublicKey">

<WriteLinesToFile File="$(HighLevelErrFile)" Lines=" ============= Operation Started =============" Overwrite="True"/>

<Exec Command ="sn -p $(SnkFilePath) OnlyPublic.snk" WorkingDirectory ="$(WorkingDir)" />

<Message Text ="Retrieved Public key from snk file and written to OnlyToken.snk"></Message>

<Exec Command ="sn -t OnlyPublic.snk > OnlyToken.txt" WorkingDirectory ="$(WorkingDir)" />

<Message Text ="Done Retrieved Public key token from snk file and written to OnlyToken.txt"></Message>

<WriteLinesToFile File="$(HighLevelErrFile)" Lines="Done Retrieved Public key token from snk file" Overwrite="false"/>

</Target>

</Project>

 

 

Posted by Sundara Prabu .T | 0 Comments
Filed under: , ,

Attachment(s): GetPublicSnk.msbuild

VSTS Tester Edition 2008, Code Coverage for WebTest works : do this

Many of us try to get code coverage using webtests, we configure for code coverage etc but end of the day we get Empty code coverage data generated. the Answer is just to follow this process... 

One should be able to get code coverage from web tests if you have the website code. But we have to have the website and your test project in a same solution; so try adding the ASP.Net website, and the test project with web tests to the same solution.

 Then select your website for instrumentation from within the testrunconfig file.

Or You can select the required Dll explicitly in the testrunconfig Code Coverage tab.

Run the WebTest.

The after test run completed, check the Code coverage results window, you will see the results.

Vsts 2008 WebTest Asp.Net UnitTest Profiling

How to Enable Code Coverage for a machine hosting the WebSite 

 

1.     The  webapp's bin folder should have all files readonly false.

2.      The second thing to do is switch off signature verification for all dlls in bin folder., using the below command

<x:\webApppath>Sn – Vr *

3.       on the code coverage setup, only check the Checkbox for  WebApp not for Dependent dlls. It automatically adds all dependencies.

 

To grant access to shared project files

  1. In Windows Explorer, locate the root of the folder tree for project files used by this user aspnet or w3wp and shared by the project team.

    The path of this folder might resemble the following:

    D:\ourProject
  2. Right-click the folder and then click Properties.

    The <folder name> Properties dialog box appears.

  3. Click the Security tab.

  4. Click the name of the user's account in the Group or user names box.

  5. In the Permissions for <user name> box, select the check box for Full Control.

  6. Click OK.

    This grants permissions to the user for the shared folder tree that begins with the folder selected in step 5. 

    To grant access to the profiling driver

    1. Open a command prompt as an administrator.

    2. Change the directory to:

      <drive>:\Program Files\Microsoft Visual Studio 9\Team Tools\Performance Tools
    3. Run the following command:

      vsperfcmd /admin:driver,start /admin:service,start
      This command installs and starts the driver for the Visual Studio Team Edition for Developers Profiling tools.

      This command starts the profiling driver and service so that non-admin users may use profiling features that are available in their User process space. Only an Administrator may run the command; and it will fail for non-administrative Users.

      Notice that the effects of this step are undone after the computer restarts, unless you also perform the final step in this procedure.

    4. Run the command to allow access to profiling driver functionality by a user or group that does not have administrator access to the computer:

      vsperfcmd /admin:security,allow,<right[,right],<user name|group name>
    5. This command grants the <user name> or <group name> account access to the Profiling tools. The <right> option determines the profiling functionality the user can access. The <right> option can be one or more of the following values:
      • FullAccess - allows access to all profiling methods including collecting performance data from services, sampling, and cross session profiling.

      • SampleProfiling - allows access to sample profiling methods

      • CrossSession - allows access to cross session profiling which is required for profiling services.

    6. (Optional) To preserve the results of any of the previous steps after computer restarts, run the following command:

    7. vsperfcmd /admin:driver,autostart,on

    The specified users, after logging on, will now be able to use the Team System profiling tools without Administrator permissions

I got these similar issues when running codecoverage , and I used the above steps for resolution.

Msbuild Dll Probing Search Path Custom

How do we make the Msbuild look in the current directory for the dlls before looking into Gac and other places .

Add something like this in your project file:

Soln 1 : 

<PropertyGroup>

<AssemblySearchPath>$(AssemblySearchPath);$(MSBuildProjectDirectory)</AssemblySearchPath>

</PropertyGroup>

or

Soln 2 :

Try this works as well .


<ItemGroup>
<CustomTaskInput Include="MyDll.dll"/>
</ItemGroup>

<Target Name="MYTarget" Inputs="@CustomTaskInput" Outputs=”abc.txt”>
<CustomTask />
</Target>

It works now, It probes the current directory for all the dll’s. Very bad that it is documented nowhere. Searched all over Msdn.

Vs 2008 Multi Target Framework and App.config behavior

The Vs 2008 , when changing the Target framework from x to y exhibits the following behavior.

 

 

Current Framework

 

Target Framework

App.config gets added / if not exists, if exists gets updated

2.0

3.0

Yes

2.0

3.5

No

3.0

2.0

Yes

3.0

3.5

No

3.5

2.0

Yes

3.5

3.0

Yes

 

 

 

 

Conclusion :

The upgrade wizard from Vs2005 to Vs 2008 does not add app.configs.

After upgrade, When we use Vs 2008 to change Target Framework from x to 3.5 never creates / updates app.configs.

GAC Post build event - Machine path independent script

Add the following 2 lines as post build event.. with this.. this is totally machine independent since it uses Visual studio macros..

 

call "$(DevEnvDir)..\..\vc\vcvarsall.bat"

"gacutil" /i "$(TargetPath)" /f

 

Posted by Sundara Prabu .T | 1 Comments
Filed under: , , ,

Silverlight 2.0 Globalization / Localization

I have created a simple Silverlight application and a doc detailing the same, on how to develop globalized silverlight apps for people across regions and cultures. www.codeplex.com/silverlight2

Created using Vs 2008 , c# and Silverlight 2.0

 

ASSERTION FAILED FAILED TO FIND PARENT ELEMENT

ASSERTION FAILED FAILED TO FIND PARENT ELEMENT (name of the dropdown control) 

I got this error after post back of modalpopupextender ajax control.

I had some cascading dropdowns on the parent page which were hooked on to dropdown controls.

Resolution 

these dropdowns were set visible false on postback of modalpopup in server side code.

Hence when the parent page did a post back it was not able to find these controls.

So, I made the dropdowns visible true in server side and used javascript to hide them instead.

document.getElementbyId returns null

I had a strange issue today.

document.getElementbyId returns null, but the object was present in the view source .

then I figured out that the javascript was executed on page load ,before the object was rendered.

Solution:

I set the defer property for the script tag, it worked

<script type="text/javascript" language="javascript" defer >

 

Posted by Sundara Prabu .T | 0 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker