Wednesday, February 01, 2006

BC30251 has no constructors

Finished developing and testing on the local machine (XP), I uploaded the latest change to the staging server running windows 2003, using the web deployment add in for VS 2005. Try to test the application an error is thrown advising that one of the user control doesn’t have a constructor. The error code was BC30251. Find the reference: http://msdn2.microsoft.com/en-us/library/s6zx0et2.aspx

A type does not support a call to Sub New(). One possible cause is a corrupted compiler or binary file.

Error ID: BC3025

To correct this error

1. If the type is in a different project or in a referenced file, reinstall the project or file.

2. If the type is in the same project, recompile the assembly containing the type.

3. If the error recurs, reinstall the Visual Basic compiler.

4. If the error persists, gather information about the circumstances and notify Microsoft Product Support Services.

Tried to recompile the application and redeploy it again doesn’t work. I tried to avoid as much as possible to reinstall the .NET framework or VS 2005. I commented few lines of code inside the user control, try again to deploy in the same way, and it worked! Finally, I moved few lines of code to other utility (helper class) and the application went perfect. Just another fun thing with new stuff .

Sunday, December 04, 2005

@@Identity Equivalent in MySql - Getting Last Inserted ID in MySQL

As a .NET Developer i really get used to Sql Server until I got a small project that require me to developed with MySql database backend. The first thing that I face with is to figure out the equivalent of @@Identity in MySql, got it , LAST_INSERT_ID() in MySql.

The second problem is how to return that function value to the application from the database. Since i am using a straight SQL. Then it turns out that below is my solution. I use execute scalar to retrieve the value of the last inserted id and use the usual executeNonQuery for update. Done.

Example:


comm = New MySqlCommand

param = New MySqlParameter("?MemberID", MySqlDbType.Int32)



If _MemberID = 0 Then

comm = New MySqlCommand("Insert Into Member(FirstName,MiddleName,LastName) VALUES (?FirstName,?MiddleName,?LastName);SELECT LAST_INSERT_ID();")

Else

comm = New MySqlCommand("Update Member( SET FirstName = ?FirstName,MiddleName = ?MiddleName,LastName = ?LastName) WHERE MemberID = ?MemberID; ")

End If

param.Direction = ParameterDirection.Input

comm.Parameters.Add(param)

comm.Connection = conn

With comm.Parameters

.Add(param)

param = New MySqlParameter("?FirstName", MySqlDbType.String)

param.Value = _FirstName

.Add(param)

param = New MySqlParameter("?MiddleName", MySqlDbType.String)

param.Value = _MiddleName

.Add(param)

param = New MySqlParameter("?LastName", MySqlDbType.String)

param.Value = _LastName

.Add(param)
conn.Open()

If _MemberID = 0 Then

_MemberID = comm.ExecuteScalar()

Else

comm.ExecuteNonQuery()

End If

conn.Close()

Tuesday, November 29, 2005

VS 2005 Professional - Unexpected error while loading DXCore

I just finished installing the VS 2005 Professional Edition. Just when i fired up the application an error box pops up.

Unexpected error while loading DXCore

Could not load file or assembly file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50215/mscorlib.dll or one of its dependencies. The system cannot find the file specified.
Type: System.IO.FileNotFoundException
Source: mscorlib
Target Site: nLoad
Call Stack:
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at DevExpress.CodeRush.Proxies.AssemblyLoader.LoadFrom(String assemblyFile)
at DevExpress.CodeRush.Proxies.AssemblyLoader.LoadFrom(String assemblyFile)
at DevExpress.CodeRush.StructuralParser.AssemblyTypesLoader.LoadCoreAssembly(FrameworkVersion version)
at DevExpress.CodeRush.StructuralParser.AssemblyModelCache.LoadCoreAssembly(FrameworkVersion version)
at DevExpress.CodeRush.StructuralParser.ProjectElement.get_SourceModel()
at DevExpress.CodeRush.StructuralParser.ProjectElement.AddReference(AssemblyReference assembly)
at DevExpress.CodeRush.StructuralParser.ProjectElement.LoadAssemblyReferencies(Project project)
at DevExpress.CodeRush.StructuralParser.ProjectElement.LoadProject(Project project)
at DevExpress.CodeRush.StructuralParser.SolutionElement.AddProject(Project project)
at DevExpress.CodeRush.StructuralParser.SolutionElement.LoadSolution(Solution solution)
at DevExpress.CodeRush.Core.SourceModelServices.InitializeService(InitializeCause cause)
at DevExpress.CodeRush.Core.ServiceManager.InitializeAll(InitializeCause cause)
at DevExpress.CodeRush.Core.CodeRush.InitializeCodeRush(DTE applicationObject, AddIn addInInstance, ext_ConnectMode connectMode)
at DevExpress.CodeRush.Shell.AddInShell.LoadDXCore(ext_ConnectMode connectMode)
OSVersion: Win32NT, 5.1.2600.131072
VSVersion: 8.0, Professional

Finally, I identified the problem. It turns out that I have uninstall the Refactor VB 2005 Beta 2 that I installed last time. After I uninstall it, then VS 2005 running smootly.

There is a new version of the refactor VB 2005 http://www.devexpress.com/vbrefactor/

.NET ROCKS!