woensdag 13 oktober 2010

ASP.NET in Delphi Prism with MySQL as database

I have made a few ASP.NET applications in Delphi 2007. I managed to get it working with a MySQL database with a DevArt DbExpress driver. To get things as users, membership and profiles running, CodeGear provided us with a few .ddl's (even with source code) with names like Borland.Data.*.dll and Borland.Web.*.dll.

I do want to get the same working in Delphi Prism (with users, memberships stored in a MySQL database). On this page I will share my quest.

I'm using:
  • Delphi Prism XE 4.0.23.741 (in Visual Studio 2010 Shell)
  • Devart dotConnect for MySQL 5.80.170.0 (trial)
  • target .Net framework 4
  • Windows 7
  • Internet Explorer 9 beta
There are two ways to start a new ASP.NET project in Delphi Prism. They are not the same... You can find a comparison on http://msdn.microsoft.com/en-us/library/aa730880.aspx#wapp_topic5.

1. menu File | New | Web Site...
2. menu File | New | Project...

I will describe my experiences in both scenarios.

1. menu File | New | Web Site...

You can choose for Oxygene as language and ASP.NET Web site. I select .NET Framework 4 as target.
I choose http://localhost/testPrism20 as HTTP Web location.

After a while the Solution is prepared.

Deploy
When you publish your website, you will have to give the password of your FTP server every time you do an update... annoying.
After adding the line customerrors mode="Off" you will get the message 'Oxygene' is not a supported language. This is easily solved by unchecking "Allow this precompiled site to be updateable" in the Publish Web Site dialog.

When I put a grid on the default page and connect it to a MySQL database it works locally. After deploying on a remote hosted site I get a 'License not found' error. As suggested in the DotConnect documentation I added a licenses.licx file. It has a context menu 'Build Runtime Licenses'. I get an error: 'Could not transform licenses file into a binary resource. Could not load file or assembly file:///C:\Windows\system32\lc.exe ...'
I copied the file lc.exe from C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\ to C:\Windows\system32\ and after a restart of Delphi Prism I could build the runtime licenses.

To use the membershipproviders I had to rename a few of the providers as documented on http://www.devart.com/dotconnect/mysql/articles/aspproviders.html.

Both locally and remote the page works.


2. menu File | New | Project...

I choose under the installed templates for Delphi Prism and Web. The only choise you than have is an ASP.NET Web Application. For the name and solution name I picked TestPrism21.

Deploy
When you publish your website you can save your FTP password.
After adding the line you will get the message 'Oxygene' is not a supported language. I cannot find an option like "Allow this precompiled site to be updateable" in the Publish Web Site dialog.
If you change the language to C# (both in global.aspx and default.aspx) it seems to work.

Both locally and remote the page works.

When I put a grid on the default page and connect it to a MySQL database it works locally. After deploying on a remote hosted site I get a 'License not found' error. As suggested in the DotConnect documentation I added a licenses.licx file. It should have a context menu 'Build Runtime Licenses'. It does not have that. There is a 'Run Custom Tool' context menu, but that does nothing.

HELP


to be continued ...




If you have some suggestions, I would like to read them !

Geen opmerkingen: