Friday, July 17, 2009

ORA-29701 when calling System.Data.OracleClient.OracleLob.Write

I recently experienced some unhandled errors when attempting to install a custom module in a DotNetNuke site that had an Oracle back end.  The DB provider I was using was AcuitiDB.

After some debugging, I was able to establish that the error was being raised from a call to AddDesktopModule, and the StackTrace showed that it was originating in a call to System.Data.OracleClient.OracleLob.Write:

[OracleException (0x80131938): ORA-29701: unable to connect to Cluster Manager

]

   System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) +304889

   System.Data.OracleClient.OracleLob.Write(Byte[] buffer, Int32 offset, Int32 count) +587

   DotNetNuke.Data.OracleSqlHelper.CreateClobParameter(String ConnectionString, String ParameterName, String p) +229

I contacted Sanjay Mehrota at Acuiti and he was very helpful in assisting me to track down the cause of this.  Firstly, he suggested that I try some other areas of the site that created clobs, such as the text/html module.  This exhibited the same error.  He also provided some test code for creating a temporary clob which I added to a simple console app as a test harness.  This initially appeared to work correctly, but when I increased the size of the string being used to around 29,000 bytes, I got the same error.  It transpires that Temporary clobs are created in the temporary tablespace and that owing to some other testing work that was being performed on the DB, we had run out of tablespace.  I got the DBA to increase the size of the temporary tablespace and the problem disappeared.

Tuesday, May 19, 2009

Asp.Net Bundle from TypeMock

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.
Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.
The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.
Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.
The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.
Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.
Go ahead, click the following link for more information on how to get your free license.

Tuesday, September 02, 2008

Must add this to my blog..

Javascript code prettifier

Friday, August 08, 2008

Simple method to serve javascript from ASP.Net

I recently needed to provide some javascript that would serve data to a third party site. My initial approach was to write a web service that could be invoked via AJAX from a script on the external page. This worked pretty well, but it required the 3rd party to configure their proxy to map to my web service. A simpler method is to just output some javascript that they could reference.

After a bit of investigation, I came up with the following:

  1. Create an asp page "TestJs.aspx" and leave the content blank.
  2. Add the following to Page_Load:
    protected void Page_Load(object sender, EventArgs e)
    {
    Response.Clear();
    Response.Write("var a='hello';");
    Response.Flush();
    }
  3. Create a page that will reference the script and add the following script tag to the head:
    <script type="text/javascript" src="TestJS.aspx"> </script>
  4. Add this test script to the body:

    <script type="text/javascript">
    alert(a);
    </script>

This technique could be used to return an arbitrary block of javascript from the webserver, without cross site scripting issues. You can also use it to pass parameters to your aspx page by just appending them to the query string of the src attribute. Indeed, this technique could be used to serve any type of text content up. Up until now, I had always thought af asp pages as dynamically constructed HTML , I hadn't appreciated that it could serve non HTML content.

Update:
About an hour after posting this, I stumbled across .ashx files, which is a more elegant method of achieving this.

Thursday, August 07, 2008

Writing to Event log with ASP.Net and Enterprise Library

I recently had a problem writing to the event log from my application.  I had configured the application to use the Logging Application Block from the 3.1 version of the Microsoft Enterprise Library and followed the walk-through in the documentation to log exceptions to the Application Log, but nothing was appearing.

I had amended the code so that it always through an exception on clicking a test button, and stepping through the code, I could see that Log.Write was being called and no error was raised from this call.

A quick search on Google suggested that this was a permissions issue for the ASP.Net account, so I added the following key:

HKLM\System\CurrentControlSet\Services\EventLog\Application\<my app name>

I granted full control to the ASPNET account to this key and amended the source property of my trace listener to <my app name> using the Enterprise Library Configuration Manager.

I now get events recorded in the Application log and their source is set to <my app name> so it is easy to filter them for the events I want.

Tuesday, March 04, 2008

Code Access Security For Child AppDomain

I recently configured an existing application to use ClickOnce deployment. All seemed to go well until I tried to run the application, whereupon it threw an exception on a line that had previously been working perfectly:

AppDomain childDomain;

childDomain = AppDomain.CreateDomain(ChildAppDomainName);

//Following line throws exception

childDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);

The exception was:

{"Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

The application was configured to run as FullTrust. To cut a long and frustrating story short, It turned out that the security settings were not being propagated to the child AppDomain. I changed the code to the following:

AppDomain childDomain;

Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;

Evidence childEvidence = new Evidence(baseEvidence);

childDomain = AppDomain.CreateDomain(ChildAppDomainName, childEvidence, AppDomain.CurrentDomain.SetupInformation);

This allowed the child AppDomain to inherit the settings from the parent domain and everything worked as expected once more.

Friday, February 29, 2008

Check for existence of DB objects

Some queries I find useful to add before the Create/Alter Statements in SQL Server.

--Constraints
IF EXISTS(
SELECT NULL FROM INFORMATION_SCHEMA.Constraint_column_usage
where table_name ='MyTable'
and constraint_name = 'FK_COl1')

--Check existence of stored_proc
IF EXISTS (SELECT NULL
FROM information_schema.routines r
WHERE r.specific_schema = 'dbo'
AND r.specific_name = 'MyProc')
--Check column exists
IF NOT EXISTS (
SELECT NULL
FROM information_schema.columns
where column_name='Col1'
AND table_name ='MyTable'
and table_schema='dbo')

--Check for description
IF not EXISTS(
SELECT NULL from sys.all_objects ao
INNER JOIN sys.extended_properties ep on ao.object_id = ep.major_id and ep.name ='MS_Description'
where ao.name ='FK_key_name')