MSMVPS.COM

The Ultimate Destination for Blogs by Current and Former Microsoft Most Valuable Professionals.
Welcome to MSMVPS.COM Sign in | Join | Help
in Search

Montaque

  • Invalid file name for monitoring: XXX path

    In .NET 1.1 , If you write code like this

    Cache.Add("key",DateTime.Now.ToString(),new System.Web.Caching.CacheDependency(@"C:/Common.config"),System.Web.Caching.Cache.NoAbsoluteExpiration,System.Web.Caching.Cache.NoSlidingExpiration,System.Web.Caching.CacheItemPriority.Default,null);

    please pay attention to the filename, even this file path is valid and you will always get the error that say invalid file name for monitoring.

    So what happend? Permission? Or Any IIS Lock Software?

    hehe, the problem is the you must write a valid file path like \\Server\A.txt

    or  C:\\Yourfile.path , So the problem is that  .NEt 1.1 determine the file path via the following code

    internal static bool IsAbsolutePhysicalPath(string path)
    {
          if ((path != null) && (path.Length >= 3))
          {
                if (path.StartsWith(@"\\"))
                {
                      return true;
                }
                if (char.IsLetter(path[0]) && (path[1] == ':'))
                {
                      return (path[2] == '\\');
                }
          }
          return false;
    }

    So change your filepath to C:\Common.config will ease the exception.ha .

    this issue has been fixed in .net 2.0,here is the code

    internal static bool IsAbsolutePhysicalPath(string path)
    {
          if ((path == null) || (path.Length < 3))
          {
                return false;
          }
          if ((path[1] == ':') && UrlPath.IsDirectorySeparatorChar(path[2]))
          {
                return true;
          }
          return UrlPath.IsUncSharePath(path);
    }

    which char is a valid directory separator? like thi

    private static bool IsDirectorySeparatorChar(char ch)
    {
          if (ch != '\\')
          {
                return (ch == '/');
          }
          return true;
    }

     

     

     

  • What's the first web 2.0 product of microsoft?

    Because of the unexpected shutdown, my outlook can not start up and it's trying to fix the storge files behind.

    then I open IE and use OWA( outlook web access). as expected,there are lots of junk mail,:)so I press delete one by one, the email are dropped . however ,the screen does not refresh ,seems it send the delete command asynchronously. and the request/response reveived are kind of web-formatted xml. so Is owa the first web 2.0 app of microsoft?

    <?xml version='1.0'?><D:move xmlns:D='DAV:'><D:target><D:href>http://Server/exchange/mmmm/Inbox/%E4%BB%8A%E6%97%A5%E7%84%A6%E7%82%B9-%E2%80%9C%E4%B8%96%E7%95%8C%E9%93%B6%E8%A1%8C%E6%95%B2%E5%93%8D%E6%96%B0%E5%85%B4%E5%B8%82%E5%9C%BA%E8%AD%A6%E9%92%9F%E2%80%9D.EML</D:href></D:target></D:move>

     

  • Sometimes, Hello world does not work;)

    I add a web method to existing web service, which return array of arraylist as the result.

    then everything workes worse, the client can not invoke either of the web method

    here is a simple code

     

    public service1: WebService
    {
     
    public service1()
    {
    }
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World, I am running in montaque notebook .NET";
            }
     
            [WebMethod]
            public ArrayList [] TestArrayList()
            {
                ArrayList [] ar=new ArrayList[1];
                ar[0].Add(1);
                ar[0].Add(2);
                return ar;
            }
     
     
    }

     

    when I test the code in the .net latest build ,40903, get the same result

     

  • Automate Business Process with Biztalk HWS and Visual Studio.net

  • Adjust the datagrid column with in edit mode

     void MyGrid_Edit(object sender, DataGridCommandEventArgs e) {
          MyGrid.EditItemIndex = e.Item.ItemIndex;
          BindMyGrid();

          DataGridItem line = MyGrid.Items[e.Item.ItemIndex];
          TextBox tb1 = (TextBox)line.Cells[0].Controls[0];
          TextBox tb2 = (TextBox)line.Cells[1].Controls[0];

          tb1.Width = Unit.Percentage(100);
          tb2.Width = Unit.Percentage(100);
          tb2.TextMode = TextBoxMode.MultiLine;
        }

    refer: http://www.atmarkit.co.jp/fdotnet/dotnettips/082wideedit/wideedit.html
  • Remember to invoke FlushFinalBlock()

    When encrypting a stream with System.Security.DesCryptoServiceProvider, code sniipt like the following.

    Byte []EncryedText=Convert.FromBase64String(this.textBox3.Text) ;

       System.IO.MemoryStream EncryptedStream=new System.IO.MemoryStream(EncryedText);

       System.IO.MemoryStream OutMS=new System.IO.MemoryStream();

       EncryptedStream.Seek(0,System.IO.SeekOrigin.Begin);

       System.Security.Cryptography.DESCryptoServiceProvider x_des=new DESCryptoServiceProvider();

       //??

       x_des.IV=m_IV;
       x_des.Key=m_Key;
       
       
       //???
       System.Security.Cryptography.CryptoStream encryptStream =new CryptoStream(OutMS,x_des.CreateDecryptor(),System.Security.Cryptography.CryptoStreamMode.Write);

       

       encryptStream.Write(EncryedText,0,EncryedText.Length);
       encryptStream.FlushFinalBlock();

       Byte[] outText=new byte[(Int32)OutMS.Length];
       OutMS.Seek(0,System.IO.SeekOrigin.Begin);
       //???????
       OutMS.Read(outText,0,(Int32)OutMS.Length);
       MessageBox.Show(System.Text.Encoding.Unicode.GetString(outText));

     

    if the FlushFinalBlock is missed, you probably will not get the full encrypted text

  • Get public key from certificate, and Convert the key to the RSAParameter

     byte[] pk = cer.GetPublicKey();
       byte[] m = new byte[pk.Length - 3];
       Buffer.BlockCopy(pk, 0, m, 0, m.Length);
       byte[] e = new byte[3];
       Buffer.BlockCopy(pk, m.Length, e, 0, 3);
       String key = "<RSAKeyValue><Modulus>" + Convert.ToBase64String(m)+"</Modulus><Exponent>"+Convert.ToBase64String(e)+"</Exponent></RSAKeyValue>";
       Console.WriteLine(key);
       RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
       rsa.FromXmlString(key);
       Console.WriteLine(rsa.ToXmlString(false));
  • Microsoft SQLXML

    SQLXML 3.0 extends the built-in XML capabilities of SQL Server 2000 with technology to create XML Web services from SQL Server stored procedures or server-side XML templates. SQLXML 3.0 also includes extensions to the .NET Framework that provide SQLXML programmability to the languages supported by Microsoft® Visual Studio® .NET, including C# and Microsoft Visual Basic® .NET.

    System Requirements

    • Supported Operating Systems: Windows 2000, Windows NT, Windows XP

    The Web Services toolkit download doesn't include the Webcasts; please download them separately.

    SQLXML 3.0 is optimized for use with Visual Studio .NET.

    This release is installed using the Microsoft Windows® Installer 2.0. You might need to upgrade your installer to Windows Installer 2.0 prior to installing SQLXML 3.0.

    Additionally, users might need to install the Microsoft SOAP Toolkit 2.0

  • Public Keys are not the same

    Aim: I wanna guarantee that only signed assembly have the access to my class library. SO I make use of the .net StrongNameIdentityPermissionAttribute to protect my assembly. When testing ,I encounter the different public keys of a same public/private key pair.

    1. Extract the public key from the keyfile

    Sn -tp montaque.snk

    the public key echos:

    Public key is
    0702000000240000525341320004000001000100eb3a0ffb39f8d13e553d77c40399287cb7f29e
    d6199da3daa9a31db7c437e0c550bae8e4bad69b7aad37ff9acc541166256d384176fe22ae6b1a
    0f5204c8c8a5ba7c8f796506fb9f4621db157830e3faef0652a89ea30c3fe53b45033c7466a3ed
    a68d8d40b4909d03e91c6f72d43f1740c10d701e74c500b8c9f491c11ae2b90fd7494f824a7ebb
    f40a2aefc8886b8f7396ef3d0e5bf2d78c66db8b69a36fdc6ed378171d5837c43c871d0ce7c47b
    61b53c36234f600072e8dfa17c13814eec657eac534c8fcd5291721f702e9b4e7d1b6c995af685
    6018e624a4435eb3d4681f83c636e374d8cf7ec38829f0b68071ed7fdf2dc243b87aa62e1d8fcd
    d65fc9773c297f59d46d270e7ffadcb457abf1ed7a73734d17e41564a223703085318bb81b21ba
    6e1724dbb32b4e79f10fc407ef835429014fe1e34b7c8e07316b5064757c47a1daba35cd3f9d53
    ee99f6ee7c0a8a5e6c7ac7e56173b9a8e02a02b301a5415dfe2089e827ae372e4a5b65058a892d
    b654669485ea9e6238f5b4a69195d58cb345586c781e0f50a23fe67c6fdd7c766f867fed718bd4
    98e8cd95dbcad5e48f0ebef977c779c71329aa6ab5c1c6596a7b8fb0df0c24ff05d967e2fa97e8
    c9e0844074b7b7bc6f45fa86d4b55cd09c3bcab03f28670e5d9fa9ad1383eeb1bbe201e290b38d
    18195d867ee066f10dd9277eaf60d45c737cbb301a955c88bf60b203e8b0ac13a887c0003d5d45
    131c6a88a8c59a094ea69fa0440b4f78fe8bb5fa1b8957ae6ae9c9671e02b08cec48b42023d2d1
    7c5ef152596caa2a890027

    Public key token is 7a2a95f64f29bc4f

    the key length is 1192

    2. extract the public key of the signed assembly.

    Public key is
    0024000004800000940000000602000000240000525341310004000001000100eb3a0ffb39f8d1
    3e553d77c40399287cb7f29ed6199da3daa9a31db7c437e0c550bae8e4bad69b7aad37ff9acc54
    1166256d384176fe22ae6b1a0f5204c8c8a5ba7c8f796506fb9f4621db157830e3faef0652a89e
    a30c3fe53b45033c7466a3eda68d8d40b4909d03e91c6f72d43f1740c10d701e74c500b8c9f491
    c11ae2b9

    Public key token is 9bcbe75a245746b6

     

    I am suprised that why two keys are not equal, does they have some relationship like mapping or hashing?

     

    sn -Tp mysignedassembly.dll

     

     

  • Message Queuing by MQSeries with C#

     
    MSMQ is the well-known Message API for windows developers. You can use MSMQ API directly by using System.Messaging class. Sometimes user needs to use IBM MQSeries especially for mainframe developers. IBM is providing a set of APIs Dotnet support pack using this we can access MQSeries. In this article I will explain the way to get and put messages using MQSeries and also will show the way to identify a particular message in queue of messages. 

    First of all we need to install the MQSeries Server in Windows 2000 server and need to install the MQSeries Client and Dotnet support pack in the client machine. Then we need to create QueueManager, Queue and Channel in MQSeries Server.

    You can download the Dotnet support pack at this link.
     
     
  • Convert C code to C#?

  • Authorization and Profile Application Block

    The Authorization and Profile Application Block is a reusable code component that builds on the capabilities of the Microsoft .NET Framework to help you perform authorization and access profile information.

     

    The Authorization and Profile Application Block provides you with an infrastructure for role-based authorization and access to profile information. The block allows you to:
    ? Authorize a user of an application or system.
    ? Use multiple authorization storage providers.
    ? Plug in business rules for action validation.
    ? Map multiple identities to a single user.
    ? Access profile information that can be stored in multiple profile stores.

    Download: http://www.microsoft.com/downloads/details.aspx?familyid=ba983ad5-e74f-4be9-b146-9d2d2c6f8e81&displaylang=en

  • using the Indexing Service with .Net

    What is the Indexing Service?

    Microsoft Indexing Service is a service that provides a means of quickly searching for files on the machine. The most familiar usage of the service is on web servers, where it provides the functionality behind site searches. It is built into Windows 2000 and 2003. It provides a straightforward way to index and search your web site.

    Setting up the Indexing Service is explained at windowswebsolutions.com and will not be covered here.

    Connecting to the Indexing Service

    The Indexing Service exposes itself to the developer as as ADO.Net provider MSIDXS with the data source equal to the indexing catalog name. For example, the connection string used in searching this site is

    Provider="MSIDXS";Data Source="idunno.org";

    As with any other ADO.Net provider you use the connection string property of the System.Data.OleDb.OleDbConnection object.

    using System.Data.OleDb;
    protected OleDbConnection odbSearch;
    odbSearch.ConnectionString =
      "Provider= \"MSIDXS\";Data Source=\"idunno.org\";";
    odbSearch.Open();
    // Query and process results
    odbSearch.Close();

    You can also use the connection string in Visual Studio by dragging and dropping an OleDbConnection onto your asp.net page and setting the ConnectionString property in the Properties tab.

     

    refer: http://idunno.org/dotNet/indexserver.aspx

  • Passing a session id to the server

    With a remoting service running in IIS I can access the session state, user,
    application, etc using the RemotingService class.

    What is the best way to pass a session from a console client to the server?
    I assume this must be done with the HTTP header, but what is the best way to
    do this?

    the same question in http://dotnet247.com/247reference/msgs/1/5553.aspx

  • A wonderful Web.config Editor

  • How to skip Windows XP Login Splash Windows.

    Click Start, Run and type "control userpasswords2", and click Ok.
    Uncheck "Users must enter a user name and password to use this computer"
    option, and click Ok
  • Microsoft's top-secret code is leaked

    Windows source code is Microsoft’s crown jewel, one that is guarded jealously. The company has to know exactly what source code is shared with partners and when.

    Some background: At one time, Microsoft shared portions of the Windows NT and 2000 source code with two partners working on software tools that would allow other software developed for Windows to run on Unix. If I recall correctly, the amount was 8 million or so lines of code for one operating system.

    That works out about right for the size of the leak, 13.5 million lines of code, according to people who have seen it. The timing fits, too, considering the apparent age of the code and when the partners had access to it. Folks who have seen the source code told me the code date appears to be July 25, 2000, which would be about right for Windows 2000 Service Pack 1.

  • C#<-->VB.NET Converter

  • Montaque and Amy got married at 2004/02/08.:)

    the photos are not ready now

  • Invalid part in cookie

        Public Sub SetCsdnCookie(ByVal c1 As System.Net.CookieContainer)
            Dim s As String = " buildtime=2004%2D2%2D3+13%3A44%fsadfasd; buildnum=1; test=0; ASPSESSIONIDQASRTDQB=EKPHCECANFKHBJLMNJEDOJDP; ASPSESSIONIDQAQSSCQA=IALDDLCAJNGDPHDLFHOCGPLD; ASPSESSIONIDSCQRSDQA=JBCKJPDADKFLJDLAPFHLBIND; daynum=7; ABCDEF=RyYqs5wAA1v7wvlXC%25252fgOhElDWk%25252fVqNFDM3t306oQtpV5vj76WrVjh7ZInURppl6i; QWERTOP=1682; userid=78486"
            'Dim s As String = "UserName=Montaque ; IP=12.121.1.1"
            s = s.Trim
            Dim reg1 As New System.Text.RegularExpressions.Regex("(?<1>[^=]+)=(?<2>[^=]+);")
            Dim mc As System.Text.RegularExpressions.MatchCollection = reg1.Matches(s)

            Dim cc As New System.Net.CookieCollection
            Dim cookie1 As System.Net.Cookie
            For Each m As System.Text.RegularExpressions.Match In mc
                cookie1 = New System.Net.Cookie(m.Groups(1).Value, m.Groups(2).Value)
                cookie1.Domain = sUrl
                cc.Add(cookie1)
            Next
            Console.ReadLine()
            c1.Add(cc)
        End Sub

     

    //How to Resolve.

    name and value of a cookie can not begin with spaces,so add a trim to the name and value

  • VS Whidbey: IDE features for building ASP.NET applications

    VS Whidbey: IDE features for building ASP.NET applications
    Agenda
    Design goals
    Area drill-downs and demos
    Summary
    VS “Whidbey” Web Themes
    Provide the best tool for building ASP.NET applications
    Project system geared for web development
    Build the richest source editor for ASP.NET and HTML
    Improve designer surface for common visual tasks – page layout, control editing
    Faster Web development
    “Whidbey” Project System
    Geared for web development
    Edit Web Sites Anywhere
    No setup required to do Web development
    IIS and FPSE supported but not required
    Built in development server for debugging
    Several options for editing web sites
    Filesystem – c:\web or \\server\web
    Direct manipulation of Local IIS (no FPSE)
    FTP
    Frontpage Server Extensions
    Web Friendly Project System
    Directory based web project system
    Better team development
    No project file locking between users
    No duplication of project file data
    Simple point-and-open folder editing enables interoperability
    Single file editing
    No project required
    Intellisense and designer support
    Remote Site Publishing
    Support for FTP, UNC, or FPSE protocols
    Visual tool for copying files to/from remote site
    Supports copy of full site, or selected files
    Copy each direction or two way synchronize
    Visually identify local and remote changes
    Detects issues and provides conflict resolution

    “Whidbey” Project System
    “Whidbey” Source Editor
    Meets all of your needs
    Intellisense Everywhere!
    HTML and ASPX markup
    Directives - <@Page, <@Register,…
    Inline code within ASPX / HTML
    Client VBScript and Jscript in <script> blocks
    <script runat=server> sections in ASPX file
    <% %> blocks in ASPX file
    Inline CSS styles
    Web.config
    XML files
    You Have Total Control
    Tools to quickly navigate your code
    Tag navigator
    Outlining for HTML / ASPX tags
    Document outline
    Drop-downs for navigation
    Inline client script
    Server code


    You Have Total Control
    Tools to quickly navigate your code
    Tag navigator
    Outlining for HTML / ASPX tags
    Document outline
    Drop-downs for navigation
    Inline client script
    Server code
    Get code to look exactly the way you like
    Full control over formatting rules
    Allows customization on a per tag basis
    New content gets defined formatting
    Validation Options
    Validate against browsers and standards
    Common browsers – IE, Netscape, Opera
    Popular web standards
    HTML 3.2 / 4.0
    XHTML 1.0 / 1.1 Transitional, Strict, Frameset
    User controllable validation
    Casing, quoting, and tag closure preferences
    Accessibility Checker
    Section 508/WCAG Compliance
    Integrated with task list
    Cleaner Code-behind
    Now using partial classes model
    Less brittle code
    No designer wire-up needed
    All the generated goop goes away
    Enables easy designer/developer interaction
    More OO code editing support


    “Whidbey” Source Editor
    “Whidbey” Design Surface
    Enhanced visual page development
    Intelligent Code Generation
    Designer never modifies your code
    100% preservation of existing formatting and whitespace
    Only modifies elements you edit
    Modern and standards based
    Design surface creates XHTML 1.1 compliant, CSS styles based code
    Generates code using your formatting preferences
    Enhanced Visual Editing
    Master pages for shared layout
    Easily maintain common look and feel
    Design surface provides visual feedback
    Improved template editing model
    Drop-down to quickly switch in/out of template mode
    Controls render default content in templates
    User control rendering on design surface
    SmartTags expose common control tasks
    Table Editing
    Easily design and build tables
    Insert pre-defined/custom table layouts
    Use table builder to define complex tables
    Table Editing
    Easily design and build tables
    Insert pre-defined/custom table layouts
    Use table builder to define complex tables
    Table Editing
    Easily design and build tables
    Insert pre-defined/custom table layouts
    Use table builder to define complex tables
    Precise table sizing using visual feedback
    New visual cues to help select rows/columns/cells
    Makes navigating tables intuitive
    “Whidbey” Design Surface
    Faster Web Development
    All the power of before, more flexibility
    RAD Development
    Faster development cycles
    Can browse changes without having to build
    Quickly test incremental updates
    Faster project open (IBuySpy Portal)
    VS 2003:  ~1 minute
    VS Whidbey:  Less than 5 seconds
    New Build Page feature
    Build and view code changes at page level
    Especially useful for C# and J#

    RAD Development
    \Code directory for class files
    Location for class files within web site
    Reference classes within ASPX pages
    Full Intellisense support
    Better team development
    Multiple developers can work on different parts of site without build conflicts
    Compile errors on one page don’t block development on others
    Directory based projects eliminate project file contention
    More Build Options
    Build and F5 behavior
    Compile errors for entire site to task list
    <asp> compilation errors to task list
    Web.config compilation errors to task list
    Optional: Section 508 / WCAG validation
    Configure F5 to your preference
    Build Site, Build Page, or Save/Browse
    Fully Compiled Sites
    Pre-compile sites for deployment
    Better performance with code-behind and ASPX compiled together
    Better IP protection
    Compilation of ASPX file allows protection of ASPX and HTML markup
    VS.NET automatically obfuscates IL upon compilation

    RAD Web Development
    Seamless upgrade
    Open, compile, run
    Full Backwards Compatibility
    Visual Studio .NET 2003 applications work
    Open, compile, and run upgrade model
    Pages updated to new code-behind syntax
    Standalone classes moved under \Code folder
    Control ASP.NET version on a directory basis in IIS
    ASP.NET 1.0 / 1.1 applications co-exist with ASP.NET “Whidbey” applications on same IIS
    Project upgrade
    Summary
    Visual Studio “Whidbey” is the best tool for building ASP.NET applications
    Many new web development features to try out today in the Alpha build
    Many more exciting new features coming in Beta
    Questions?
    Brian Goldfarb (bgold@microsoft.com)
    http://blogs.gotdotnet.com/bgold/
    Omar Khan (omark@microsoft.com)

    Download Slides/Demos
    ASP.NET Whidbey Book
    Now available for PDC bits
    13 Chapters, 470 Pages
    Topics Covered
    Introduction, Tools & Architecture, Data Source Controls and Data Binding, GridView & DetailsView Controls, Master Pages & Navigation, Security, Personalization & Themes, Web Parts, Mobile Device Support, SQL Cache Invalidation, Precompilation, Confuguration & Administration and more.
    ASP.NET 2.0 Hands-On Labs
    Great Hands-on Walkthroughs (8 hours worth!)
    Located in Petree Hall (proctors available for questions)
    Nine Labs
    Introduction
    Data Controls


     

  • the next generation of VS.NET

    • Visual Studio code name "Whidbey" (2004). This release of Visual Studio and the .NET Framework will offer innovations and enhancements to the class libraries, common language runtime (CLR), programming languages, and the integrated development environment (IDE). In addition, this product will provide deep support for SQL Server code name "Yukon" by enabling developers to write stored procedures using managed code.
    • Visual Studio code name "Orcas" (2005). This version of Visual Studio and the .NET Framework will provide tools support for the Windows operating system, code name "Longhorn."

    http://msdn.microsoft.com/vstudio/productinfo/roadmap.aspx

  • MSBuild-the Next generation build engine

    MSBuild is the [extensible, scalable, transparent] next generation build engine and platform for Visual Studio .NET.  Many of our sharpest PMs, developers, testers, and yes, even writers, are feverishly working on this project.

    more information about MSbuild.exe , there is a webcast about this tool:

    http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20040122VSNETAK/manifest.xml

  • Windows Server 2003 Web Edition Dos not support SQL Server.

    that's a limitation of the version.
  • Testing Chinese Encoding...

    Thanks Susan First!

    The Traditional Chinese New Year is coming around the corner, Happy Chinesee Year to you all:-D

This Blog

Post Calendar

<June 2006>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

Post Categories

Syndication

Powered by Community Server, by Telligent Systems