Huge amounts of data WCF \ Silverlight

18. March 2011 04:03 by Mrojas in General  //  Tags: , , , , , , ,   //   Comments (0)

 

Today I found this excellent post:
http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/ 
and I was the key to solve a problem I had with a WCF service.

I had made some changes to an application to send a text file to the server
for batch processing, everything was working fine until I started sending big files.

I just received one of those obnoxious Not Found error.
So what could I do? Well as any respectable WCF developer would I started tracing the WCF messages with Fiddler, and I found this:

If you cannot read it from the image the message was:

DeserializationFailed… The formatter threw an exception while trying to deserialize the message:
There was an error while trying to deserialize parameter :_xxxxxx.
The InnerException message was 'There was an error deserializing the object of type System.String.
The maximum string content length quota (8192) has been exceeded while reading XML data.
This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas
object used when creating the XML reader.

I was a little confused but thanks to that post I was able to just add:

          <binaryMessageEncoding maxWritePoolSize="16" maxSessionSize="8192">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                                   maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binaryMessageEncoding>
 
 

And got everything working again!

Doing Backups in Windows Azure

17. March 2011 03:47 by Mrojas in Azure  //  Tags: , , ,   //   Comments (0)

When we migrate our customers to Azure, we want them to take advantage of
this rich platform.

Even for a simple deployment you get a Windows Azure Storage Account,
and that account means up to 100TB of storage!!!!! So take advantage of that.

One common thing that any enterprise needs is backups.
You need to backups of you email files, databases, documents, etc.

Sometimes you can have a dedicated server for storing that data, but
all hard drives can fail, so you will need to make several copies of your
backup information, probably use a RAID disk, make backups of your backups
on tape, DVD, etc…

What if you could just use your cloud storage, which is triplicated in secure datacenters?

Well you can!

There are currently several solutions.

For example in codeplex you will find projects like: http://myazurebackup.codeplex.com

MyAzureBackup provides simple to use web user interface.
I have even extended some of its functionality to work with a Windows Service that uses
a FileWatcher to upload files from a directory.
And it is easy to use this application as a base for your backup infrastructure adding some
security functionality like encrypting files.

So go ahead and explore all the new posibilities you have with cloud computing

Tracking Bugs in Windows 7

11. March 2011 04:05 by Mrojas in General  //  Tags: , , , , , ,   //   Comments (0)

Is very common that a user calls you to report a bug,
but it takes you a long time to understand what really happened.

Well Windows 7 has a great tool call the Problem Step Recorder.

This post will provide a good intro using this tool: http://www.blog.jbi.in/tipsntricks/how-to-use-problem-steps-recorder-in-windows-7/

 

 

Azure Migration: ASP.NET Site with Classic Pipeline mode

Recently while we were performing the migration of a blog engine in ASP.NET to Azure we had to deal with some issues with
the differences between IIS6 and IIS7.

Windows Azure Web Roles, use IIS7, with Integrated Pipeline mode and that is a breaking change for some ASP.NET sites.

The are at least two main changes:

 

First  is for HTTP modules and handlers.(This info was taken from: http://arcware.net/use-a-single-web-config-for-iis6-and-iis7/)

" For IIS6, they were configured in the <system.web> section, as such:

 

        <httpModules>
            <add name="..." type="..." />
            <add name="..." type="..." />
            <add name="..." type="..." />
        </httpModules>

        <httpHandlers>
                 <add  verb="..." path="..." type="..." />
                 <add  verb="..." path="..." type="..." />
        </httpHandlers>

However, to get these to work in IIS7 you must *move them* from the <system.web> section to the new <system.webServer> section, which is what IIS7 requires when running in Integrated Pipeline mode (it’s not needed for Classic Pipeline mode)

 

So instead of the above you have this instead:

<system.webServer>
    </modules>
        <add name="..." type="..." />
    </modules>
    <handlers accessPolicy="Read, Write, Script, Execute">
        <add verb="...." name="..." path="..." type="..." />

</handlers>
</system.webServer>

Notice there are a couple slight changes, which means you can;t just copy and paste
these as-is from <system.web> into <system.webServer>:

<httpModules> and <httpHandlers> have been renamed to <modules> and <handlers>, respectively.

Each handler in IIS7 requires a name attribute. If you don;t specify it, you'll get an error message.

The handlers node has an optional, but good-to-define accessPolicy attribute.
This value depends on your handlers, so use the ones that are right for you."

Second
There are some restrictions in IIS7 when you are running in Integrated mode.
For example you cannot do calls to the request property of an HttpContext object.
All calls to HttpContext.Current.Request will have a problem because Request will be null.

You can see more details here:

http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx

 

Coldfusion cfdocument bug with images and Windows Authentication

4. March 2011 16:52 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

If you are running your Coldfusion Server with IIS7 and you use Windows Authentication you should be aware that you might
encouter a bug if you try to use a cfdocument tag like:

 <cfdocument format="pdf">

Hello World <img src="images/world.png">

</cfdocument>

The problem here is that Coldfusion will use http to get the image when building the PDF, and because this site uses Windows Authentication it crashes.

How to solve it?

 <cfdocument format="pdf" localUrl="true">

Hello World <img src="images/world.png">

</cfdocument>

This solves this bug and also improves perfomance because CF will convert images/world.png to a physical path like file://E:/images/world.png

Running Coldfusion on a Web Server Role

4. March 2011 15:43 by Mrojas in General  //  Tags: , , , , , ,   //   Comments (0)

I have been playing around with one of my test Azure Web Roles to determine
if it is possible to run it inside Azure, using a Web Role not just a VM Role.

So far I have been able to run Coldfusion 8 in a Web Role, but I have not been able to fully automate this task,
I had to do a remote desktop to the Web Role and perform the following tasks:

  • Add Features to the Web Roles particulary II6 Management Compatibility
  • Make sure that the Handlers for CFM, CFML, CFC are inplace

IIS Handler CF

  • And make sure that the ISAPI is ok:
  • Once all that is set you can run Coldfusion 8 in your Web Role. Now we just need to automate all the CF8 installation in a Web Role,
    but that will be something another post

 

Control Property Serialization in .NET

While solving a bug with a custom class that extended the System.Data.DataSet class, I found a situation where the class implemented, the ISerializable interface, but for some reason, during the call to the base.GetObjectData in my serialization code it was trying to get the value of some properties that caused an exception.

The reason was that those properties were not “ready” because my serialization code had not finish initializing the object. But why was the Dataset.GetObjectData trying to get or set those values.

It seems that there is some code in the dataset that used reflection to get the object properties and try to serialize them. I did not want that.
How could I stop the framework from doing that?


I thought of the NonSerializable attribute but that works only on fields and what I have is a property.

I thought of the XmlIgnore attribute but it had no effect.

Why!!!!

Well I finally found that you can add a couple of (not attributes) methods to your component.

They should be named Reset<Property>() and ShouldSerialize<Property>() and returning a boolean value
from these functions will control if the properties are serialized or not.

For more info see MSDN page for ShouldSerialize

Problems installing the Windows Phone 7 Tools

1. March 2011 04:18 by Mrojas in General  //  Tags: , , , , , ,   //   Comments (0)

If you are getting ready to migrate your applications to Windows Phone,
you have to install all the neccesary Windows Phone Stuff.

However you might have incompatibilities in your dev machine.

This post: http://blogs.msdn.com/b/astebner/archive/2010/07/12/10037442.aspx

Is great. I used it to identity why the installation tool insisted that
I had a Windows Phone Emulator installed in my machine. It seems that it looked for something like XDE.

So if you have this same issue or something similar just take a look at that post, it might be of great help

ASP Migration COM+ and security

18. February 2011 02:53 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

Typical ASP applications were built as a layer of simple ASP with some
COM+ components that did the heavy lifting.

Now, when you migrate your ASP application to ASP.NET and you also migrate your
COM+ components to .NET then you might encounter some issues with security.

One common issue is impersonation.

Sometimes the COM+ were created to use the current user account.

clip_image002

 

clip_image002[6]

And there is a slight 
difference between ASP and ASP.NET:

“Impersonation is when ASP.NET executes code in the context of an authenticated and authorized client. By default, ASP.NET does not use impersonation and instead executes all code using the same user account as the ASP.NET process, which is typically the ASPNET account. This is contrary to the default behavior of ASP, which uses impersonation by default. In Internet Information Services (IIS) 6, the default identity is the NetworkService account.”

That will cause errors in your ASP.NET application like:

 

clip_image002[8]

To solve this issue you must use ASP.NET Impersonation, and to enable impersonation go to the web.config file and add:

<identity impersonate=”true”/>

For more info on impersonation see: http://msdn.microsoft.com/en-us/library/aa292118(v=vs.71).aspx

Problems Debugging Silverlight with VS 2008

31. January 2011 10:58 by Mrojas in General  //  Tags: , ,   //   Comments (0)

If for any reason you have to debug and develop Silverlight VS 2008,
and you encounter a problem that when you start debugger it reports
something as if the version you have is not supported then first do this:

Open regedit and check:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight\Components\Debugging\Value

A Version value of 4.0.50917.0 means that you have the Silverlight 4 Developer and you need to:

1. erase this entry.

2. Uninstall Silverlight 4 Tool

3. Reinstall Silverlight 3 Tools for Visual Studio 2008.