Decrypting app.Config

Do you need to decrypt an app.config file? There are lots of directions explaining the process if you’re dealing with a web application, but if you’re dealing with a windows app or a service of some sort, you don’t have a web.config…  all you have is an app.config. The process isn’t all that different.

Here’s what an encrypted app.config “appSettings” section might look like. Continue reading

CustomPrincipal and Serialization

Recently, I’ve been working on a project that relies on a backend business object layer.  The business object (BO) layer, requires authentication in order to be used.  For most of the systems, this is okay, but my project is to be used by end users.  We don’t need to authenticate the users… we need to authenticate the system.

This is easy enough using the CustomPrincipal object in Rocky Lhotka’s CSLA framework (which is also being used).  We simply create the CustomPrincipal and add that to the ApplicationContext. Continue reading

Release Mode error message

We’re approaching delivery of the baby!  In the next few months, we’ll be releasing our product.  This is great news as it’s been a long time coming.  As is the norm, we’ve been developing our product in Debug mode.  While in Debug mode, Visual Studio will generate extra files to allow stepping through the code.  This is a great thing for creating the initial code, but it’s not necessary for code that’s deployed to the world at large.

When I switched Visual Studio over from Debug mode to Release mode, I got a weird error. Continue reading

System.Runtime.InteropServices.COMException

Recently, we’ve had some fairly serious problems on our network. This has led to the admin staff removing our network profiles. It was an accident, but it still happend. The problem is now that the entire IT staff has to reconfigure our workstations.

We’re using Visual Studio 2008 for our web applications. I finally got my code base updated via Subversion (no small feat) and tried to open a solution. I was presented with an error message stating:

System.Runtime.InteropServices.COMException

It appears this is caused by IIS not being installed or properly configured.  Since my network profile had to be rebuilt my rights need to be reset also.  They didn’t make me an administrator of my box so I can’t check it.

Continue reading

The case for ‘IN’

Recently I was doing a little SQL. Just straight SELECT * FROM… kind of SQL. I had a where clause that was working perfectly. It was:

WHERE field1='P' or field1='U'

I ran into a situation where I needed to get a particular row. I had the primary key value so I just threw that into the WHERE clause. Now, instead of getting a single row, I got 73! What?! Examining the WHERE clause shows the obvious problem.

WHERE field2=12345 AND field1='P' or field1='U'

Duh… Using the AND and OR together really screwed it up. It was an easy fix though. I could have solved the problem with some parentheses but decided to use an IN clause instead. It lends itself to be more readable and less confusing.

WHERE field2=12345 AND field1 IN ('P','U')

ORA-25408: Can not safely replay call

I have a system at work that imports data from the old system to our new system.  Given that the new system is very object oriented, performing a straight conversion is not really possible.  As such, we have this importer system.

During the imp0rt, I ran into a very strange problem.  While trying to fill a dataset from Oracle, we get the error:

ORA-25408: can not safely replay call

Weird.  Time for some research…

It looks like the ORA-25408 error has to do with some sort of “failover” event at the server.  It seems highly unlikely that this is actually what I’m running into.  However, I do know that our connection to the server farm is sketchy.

I updated the system with a Try/Catch block.  Now, if the dataset fails to fill, the system will sleep for 1 second and try again.  If it continues to fail, I’ll have to look into it further.

ORA-00911: invalid character

What a weird thing…  Here I am coding along with everything happy.  Basically, I’m just writing a utility program that will read records from one table, do a little processing and then write the data to another database.

One of my statements reads like this:

strSelectText = "SELECT * FROM VALID_TERM_TYPE;"

That’s cool… it works just like I would think it would.  Another statement needs some criteria on it.  That statement reads like this:

strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS='P';"

No problem, right?  Buuzzzzzz….  When I try to execute that statement, I get the following error:

“Oracle.DataAccess.Client.OracleException ORA-00911: invalid character    at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at MajorsImporter.Form1.Button1_Click(Object sender, EventArgs e) in C:\svn\MajorsDB2K8\MajorsImporter\Form1.vb:line 239″ “Oracle.DataAccess.Client.OracleException ORA-00911: invalid character    at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)   at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)   at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)   at MajorsImporter.Form1.Button1_Click(Object sender, EventArgs e) in C:\svn\MajorsDB2K8\MajorsImporter\Form1.vb:line 239″

What the heck?!

I examine the statement again and everything looks right.  Maybe I need to use double quotes instead:

strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS=""P"";"

NOPE.  Arg…. mabye if I escape them like in C or something…:

strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS=\"P\";"

NOPE.  Double Arg.  I do a little researching and discover that when I add the criteria to the select statement, I have to leave the semi-colon off the end!!

strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS='P';"

WOW… who would have thought that with no criteria, you the semi-colons are optional, but with criteria they’re forbidden.

Stupid computers…. who needs’em?

Stupid Data Type problems

Why why why… why do all companies have to have their “own” date formats?  I’m trying to insert some records into an Oracle database from a VB.Net application.  The oracle datatype is DATE.

So in my stored procedure call, I try to format the value as a date.
objCommand.Parameters.Add(“iStartDate”, CType(StartDate, Date))
No luck.  I get an error telling me that there’s an invalid character or some such thing.  In order to insert the record I have to format it.
objCommand.Parameters.Add(“iStartDate”, Format(CType(StartDate, Date), “dd-MMM-yyyy”))
Again… not a huge deal.  Just something else to get me cranky.

Properties and Web Services

Such a weird thing…  the project I’m working on is using a distributed architecture.  Everything is all on my workstation, but the architecture is split out into a web service as one project and the UI as a separate project.

I just ran into a very strange situation where some properties of the objects in the web service weren’t exposing themselves!  Even if I tried to use the web service itself by accessing the .ASMX page… they just weren’t there.
It turns out that I had marked the properties as READONLY and for whatever reason, that was preventing them from coming out in the web service return object.
YARG.  >:-(
I removed the READONLY attribute and just set the setters to do nothing.  Finally!  Back to work.