Microsoft .NET Source Code Download

by Robert Amiscaray 10. January 2012 05:14

Downloads for Microsoft .NET Framework. 

http://referencesource.microsoft.com/netframework.aspx

Available for download are:

.NET    3.0,

ASP.NET MVC 1.0,

ASP.NET MVC 2.0

ASP.NET MVC 3

WCF    3.5SP1

WF    3.5SP1

Dotnetfx_Win7_3.5.1  3.5.1

.Net    4

.NET_3.5_sp1_redist  50727.3053

Netfx_3.5.1_Win7SP1  3.5.1 V

Currently rated 1.5 by 444 people

  • Currently 1.472973/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Development

Microsoft All-In-One Code Framework

by Robert Amiscaray 9. January 2012 18:48

Great code examples from Microsoft 

http://1code.codeplex.com/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Development

Free Suse Linux Training CourseWare from Novell

by Robert Amiscaray 8. January 2012 17:34

Currently rated 1.4 by 10 people

  • Currently 1.4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Operating System | Training | Suse Linux

Using JQuery.UI, A DatePicker shows behind a modal dialog box fix.

by Robert Amiscaray 7. January 2012 17:49

After doing a using a DatePicker with modal dialog window, it appeared behind the dialog window.  To correct this, you can extend it.

$.extend($.datepicker, {

afterShow: function(event) {

$.datepicker._getInst(event.target).dpDiv.css('z-index', 100000);            

}

});

$('#DateOfBirth').datepicker().focus(function (event) {

$.datepicker.afterShow(event);

});

Currently rated 1.5 by 18 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

JQuery

XElement - Xml nbsp parse exception

by Robert Amiscaray 10. October 2011 07:33
While trying to Parse xml, you might come across an error for  
                    XElement.Parse(someXMLContent);
"Reference to undeclared entity 'nbsp'. Line 5, position 59."
using this will resolve it. 
                    XElement.Parse(@"<!DOCTYPE documentElement[
                        <!ENTITY nbsp ""&#160;"">
                        <!ENTITY ndash ""&#8211;"">
                        <!ENTITY mdash ""&#8212;"">
                        ]>" + someXMLContent);

Currently rated 1.4 by 9 people

  • Currently 1.444444/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Bugs | Development

SSL TransportWithMessageCredential IIS WCF Service using DTC Transactions

by Robert Amiscaray 18. March 2010 11:52

Steps to Success with SSL TransportWithMessageCredential with IIS WCF Service and Sql Server Database with Transactions

 

Certificates

Ensure Server has a Certificate installed.

Grant permission to the Certificate to the IUSR_XX, Network Service

Configuring PORTS

If you have a Firewall 

1)  Ensure Port 135 (RPC) is open between the Web Server and Sql Server

2)  If using Windows Server 2003, you should open a recommended 20 ports for DTC.  Microsoft Recommends using ports 50000 and above.  See previous blog

Server Accessibility

1)  You should be able to ping other box by name.

Example:  Server 1 (MyWebServer) should be able to ping Server 2 (MyDBServer)

from MyWebServer:

ping MyDbServer

from MyDbServer:

ping MyWebServer

You might need to create a LMHOSTS file that maps the name to an IP.  This is typically created and stored in C:\Windows\System32\Drivers\etc

From Command Prompt

type nbtstat -R to refresh the list 

type nbtstat -c to show current list

Configuring DTC

1)  At the Run prompt, type "dcomcnfg"

Verify DTC enabled and configure on both Web Server and Sql Server

3)  Security Settings : Network DTC Access > checked

4)  Client and Administration : Allow Remote Clients > checked

5)  Client and Administration : Allow Remote Administration > checked

6)  Transaction Manager Communication : Allow Inbound > Checked

7)  Transaction Manager Communication : Allow Outbound > Checked

8)  Transaction Manager Communication : No Authentication Required > Selected

Reboot the PC for the server(s) to pick up the changes.

IIS WCF Service Configuration File

  <system.serviceModel>
    <services>
        <service name="MyService" behaviorConfiguration="MyService.ServiceBehavior">
        <endpoint address="" binding="wsHttpBinding" contract="MyService.Interfaces.ICalculatorService" bindingConfiguration="WSHttpBinding_ICalculatorService">
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://www.enterpriseframework.com/CalculatorService"/>
            </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyService.ServiceBehavior">
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyService.ServiceUserValidator, MyService" />
          </serviceCredentials>
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"  />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ICalculatorService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="true" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
            <security mode="TransportWithMessageCredential">
                <transport clientCredentialType="Certificate"/>
                <message clientCredentialType="UserName"></message>
            </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>


Client Config File

    <system.serviceModel>
        <client>
            <endpoint address="https://www.enterpriseframework.com/CalculatorService/CalculatorService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculatorService" contract="CalculatorProxy.ICalculatorService" name="WSHttpBinding_ICalculatorService" behaviorConfiguration="CalculatorBehavior"></endpoint>
        </client>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_ICalculatorService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="true" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="10000" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="100384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="Certificate" />
                        <message clientCredentialType="UserName"></message>
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <endpointBehaviors>
                <behavior name="CalculatorBehavior">
                    <clientCredentials>
                        <clientCertificate findValue="1e25dd5dca23433310e9873efc3e5f2efa123555" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
                    </clientCredentials>
                    <callbackDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </endpointBehaviors>
        </behaviors>
    </system.serviceModel>

Internet Accessible WCF Service

1)   Turn WS-AT on for the web server using WSATCONFIG.EXE found in C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation

Parameter would look something like:

WsatConfig.exe –network:enable –port:443 –endpointCert:1e25dd5dca23433310e9873efc3e5f2efa123555 -accountsCerts:1e25dd5dca23433310e9873efc3e5f2efa123555 -restart


Show the current status for WS-AT

wsatconfig.exe -show

Currently rated 1.5 by 28 people

  • Currently 1.464286/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , ,

Development | Windows

ASP.NET on Windows Server 2003 to SQL Server 2005 on Windows Server 2008 using DTC

by Robert Amiscaray 5. February 2010 05:43

Steps to Success for ASP.NET on Windows Server 2003 to SQL Server 2005 on Windows Server 2008 using DTC on a Specific Ports (Firewall from Web App to Database)

1)  On both Windows Server machines I have enabled DTC as followed on http://technet.microsoft.com/en-us/library/cc753510%28WS.10%29.aspx.

2)  Rebooted both machines and verified both DTC services running.  Rebooting is annoying but it has to be done

3)  Ran Tests doing a transaction were Successful from the ASP.NET to Sql Server 2008.  The app ran as expected and the Transaction Statics showed Activity and successful commits.


Here are my steps to make both servers use DTC port over a specific port.

NOTE:  You cannot use DTC over only one port.  It must be over a range of ports (Example:  Ports 50000-50020)

1)  DTC uses RPC which is Port 135.  This must be opened on the Firewall

2)  On the firewall be sure to open the ports 50000-50020.  TCP and possibly UDP.

2)  On both Windows Servers, I followed the steps on http://support.microsoft.com/kb/250367/en-us#appliesto so I ended up with the following registry settings on both Servers:

  HKEY_LOCAL_MACHINE\Software\Microsoft\Rpc\Internet 

  Ports : REG_MULTI-SZ : 50000-50020
  PortsInternetAvailable : REG_SZ : Y
  UseInternetPorts : REG_SZ : Y

2)  Rebooted both Servers. (Confirmed I did both).  Again....Rebooting is annoying but it has to be done

3)  Ran Tests doing a transaction were Successful from the ASP.NET to Sql Server 2008.  The app ran as expected and the Transaction Statics showed Activity and successful commits.

Documentation on DTC is wrong.  In a Microsoft Support page http://support.microsoft.com/kb/250367/en-us#appliesto it gives an example of using a single PORT.  Which this does not actually work.

Troubleshooting

1)  You must be able to ping the other machine by name.  If you are not able to ping the other box, you must add a record to LMHosts

2)  Sometime permissions will effect the DTC

Microsoft Recommended with Windows Server 2008 that ports 50000 and above be used with DTC.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Windows

Apple IPad - A Giant Giant Version of a IPOD touch

by Robert Amiscaray 2. February 2010 05:33

What a piece of crap

Wow, this product has fail written all over it.  But there is always going to be a lot of Apple fans who applaud it because it's a giant sized version of IPod Touch.  I mean honestly it's a joke.

  • You can't multitask
  • You can't make a phone call with it
  • It doesn't come with a QWERTY keyboard
  • It doesn't have a web cam
  • It has has small hard drive space

What a joke.  You could buy a Notebook or a Netbook.

APPLE FAIL

Currently rated 2.0 by 21 people

  • Currently 1.952381/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Humor

Encrypting Data Sections within ASP.NET 2.0

by Robert Amiscaray 22. January 2010 05:48

Great article on how to for Encrypting Configuration Sections in ASP.NET on MSDN.Microsoft.com

using DPAPI

using RSA

Currently rated 1.5 by 22 people

  • Currently 1.454545/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Development

Multi-Machine Encryption and Decryption Steps to Success

by Robert Amiscaray 21. January 2010 12:01

Encryption Problems - Machine Key, Symmetrical Key, Rijndael, Encrypt/Decrypt across multiple machines

I recently created a SSO (Single Sign On) system.  This envolved using the Cryptography Application Block 4.1 from Microsoft.  There is a Web Application that talks to a backend WCF authentication service.  Both typically sit on the same machine.  The scope of this is that some user data would be encrypted within the database and is access through the WCF Authentication Service.  This would be done on three different environments (Dev, QA, PROD).  I need to be able from my Dev box connect to each WCF Authentication Service on any environment and encrypt and decrypt the data.  I thought this would be a walk in the park.  However this was not as simple as I thought it would be.   

My Setup:

Developer Environment:

Windows 7 developer box

Visual Studio 2008

IIS 6

Enterprise Library 4.1 (Specifically using Cryptography Application Block)

QA Environment:

Windows Server 2003

IIS 6

PROD Environment:

Windows Server 2003

IIS 6

If not done correctly, you could come across the following errors:

Padding is invalid and cannot be removed
Stack Trace:
at
System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) at
System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) at
System.Security.Cryptography.CryptoStream.FlushFinalBlock() at
System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) at
System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) at
System.Web.UI.Page.DecryptString(String s) at
System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString)

Key not valid for use in specified state

System.InvalidOperationException: Key versions do not match between encrypted key and decryption algorithm
at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.KeyReaderWriter.Restore(Stream protectedKeyStream, String passphrase)
at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.KeyReaderWriter.Restore(Stream protectedKeyStream, String passphrase, DataProtectionScope protectionScope)
at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.KeyManager.RestoreKey(Stream inputStream, String passphrase, DataProtectionScope protectionScope)
at Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Configuration.Design.CryptographicKeyWizard.btnFinish_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Enterprise Library Configuration - Export Key Wizard : An error occurred exporting the key 

Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirement of the domain. 

The Steps to Success to have you up and running on multiple environments:

Step 1.  I use this code from Microsoft to generate a Machine Key How to create keys by using Visual C# .NET for use in Forms authentication

This would be the same across all environments.  You need this if you want to decrypt across many machines.

Step 2.  I use the generated MachineKey (using GenerateKey.exe 24 64)  and place the generated MachineKey into the Web.Config of my Web Application and WCF Authentication Service

Step 3.  Open Enterprise Library Config tool and

  1. Right click Enterprise Library Configuration > New Application
  2. Right click Application Configuration > New > Cryptography Application Block
  3. Right click Symmetric Providers > New > Symmetric Algorithm Provider
  4. (Type Selector - System.Security.Cryptography.SymmetricAlgorithm) : RijndaelManaged is by default selected, click OK
  5. (Cryptographic Key Wizard) : Create a new key is by default selected, click Next >
  6. (Cryptographic Key Wizard) : Click on Generate (auto populates text area), click Next > 
  7. (Cryptographic Key Wizard) : Choose a file to export the key to:  Example:  Generated.Key
  8. (Cryptographic Key Wizard) : Please select the data protection mode : Choose Machine, click Finish
  9. Take the new created file Generated.key and copy it into my web application and WCF Authentication Service.
You will see that RijndaelManaged now appears under Symmetric Providers.
  1. Right Click RijndaelManaged > Export Key (This step is important.  It appears there is a bug Entprise Library Config on trying to open the key later on and trying to export.  You will end up getting the error:  Enterprise Library Configuration - Export Key Wizard : An error occurred exporting the key)
  2. Enter a File name - This will take the key for the algorithm, encrypt it with a password and saved to a Text file
  3. Enter a "Password" and "Confirm Password".  SAVE THE PASSWORD IN A SAFE PLACE
  4. Click OK

Now that you have created the Key Text file, there are two things you can do if needing to use the key on another machine:

  1. You can take the exported Key Text File to another machine
    1. Copy Key text file to new machine
    2. Click on Start > All Programs > Microsoft Patterns and Practices > Enterprise Library 4.1 - October 2008 > Enterprise Library Config
    3. Click File > New Application
    4. Right Click Application Configuration > New > Cryptography Application Block
    5. Type Selector - RijndaelManaged (default), click OK
    6. Right click Symmetric Providers > New > Symmetric Algorithm Provider
    7. Cryptographic Key Wizard:  Import a password-protected key file, Click Next
    8. Cryptographic Key Wizard:  Select the originally created Text Key file and enter the password, click Next
    9. Cryptographic Key Wizard:  Enter a filename to export the .Key file to, Click Next
    10. Cryptographic Key Wizard:  Machine Mode, Click Next
    11. Cryptographic Key Wizard:  Click Finished
    12. Click Save, this will create the Algorithm Key file
  2. Write a program to automatically read the Key Text file and create a new Symmetric Key specific to that machine. 
    1. Here is a post by DevLingo on automatically converting the Key Text file back into a Symmetric Key specific to that machine. 
    2. Here is a C# version of the DevLingo VB code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;


namespace EnterpriseFramework.Security.Console.GenerateValidationKey
{
    public class GenerateNewAlgorithmKey
    {
        //Private class members
        private static string SECURITYKEYFILE = "XFileSecurity.key";
        private static string KEYIMPORTFILE = "ColorIndex.txt";
        private static string KEYIMPORTFILE_PW = "color2007";

        public void GenerateNewKey()
        {
            RewriteAlgorithmKey("ColorIndex.txt", "color2007", "XFileSecurity.key");
        }

        private bool RewriteAlgorithmKey(string importKeyTextFile, string importKeyTextFilePassword, string keyExportFilename)
        {
            bool secure = false;
            string sCurrentPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            do
            {
                sCurrentPath = sCurrentPath.Remove(sCurrentPath.Length - 1);
            } while (sCurrentPath.EndsWith("\\"));

            string importFile = sCurrentPath + importKeyTextFile;
            string exportFile = sCurrentPath + keyExportFilename;

            if (!System.IO.File.Exists(exportFile))
            {
                ProtectedKey key = KeyManager.RestoreKey(File.Open(importFile, FileMode.Open, FileAccess.Read), importKeyTextFilePassword, DataProtectionScope.LocalMachine);
                KeyManager.Write(File.Open(exportFile, FileMode.Create), key);
            }

            Configuration cfg = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            if (cfg.HasFile)
            {
                ConfigurationSection cryptoSection = cfg.Sections["securityCryptographyConfiguration"];

                if (cryptoSection != null)
                {
                    CryptographySettings cryptoSettings = cryptoSection as CryptographySettings;
                    SymmetricProviderData data = cryptoSettings.SymmetricCryptoProviders.Get(0);
                    string sSetPath = data.ElementInformation.Properties["protectedKeyFilename"].Value.ToString();
                    if (sSetPath != exportFile)
                    {
                        data.ElementInformation.Properties["protectedKeyFilename"].Value = exportFile;
                        cfg.Save(ConfigurationSaveMode.Minimal);
                    }
                    secure = true;
                }
            }

            return secure;
        }
    }
}
 

Great Encoding/Decrypt example http://blogs.msdn.com/shawnfa/archive/2005/11/10/491431.aspx 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About Me

My Name is Robert Amiscaray and I have been developing for 14 years.  I am a MCSD (Microsoft Certified Solutions Developer) and primarily use Microsoft Based Technologies.