yasser777 / nettiers

Automatically exported from code.google.com/p/nettiers
0 stars 0 forks source link

Support of SQL Azure 2012 Connection string #430

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. I have used the 'IsConnectionStringAzure' to use the cloud configuration 
file instead of web.config
2. I have also added the required configuration to the cloud configuration file 
for connecting string as mentioned on 
http://community.codesmithtools.com/nettiers/f/16/p/10124/37948.aspx#37948 

What is the expected output? What do you see instead?

I was expecting that the solution will read the connection string from cloud 
configuration file and solution works fine with it.

But instead i get "Object reference not set to an instance of an object" error 
on the line 

settings.ConnectionString = 
RoleManager.GetConfigurationSetting("netTiersConnectionString");

under datarepository.cs file. 
in debug i found RoleManager.IsRoleManagerRunning = false.  seems role manager 
has not started. I did not find any code to instantiate RoleManager in the file

What version of .netTiers and CodeSmith are you using?

I am using CodeSmith Generator Professional 6.5.2 Revisoin 14758
and .netTiers v2.3.1

Please provide any additional information below.

While investigating i have realized that the netTiers Azure consideration is 
for the old version of AZURE 2009 but on my machine i have AZURE OCT-2012 
version. So, i have decided to update the template.

I have done following modification to the template to make it working with 
AZURE OCT 2012 version. Just logging here to track it as i have been advised in 
my post on community forum 
http://community.codesmithtools.com/nettiers/f/16/p/12857/49935.aspx#49935

Following is what i did..

The issue was not able to load the RoleManager. But in my other Windows Azure 
project i am not using the 'Microsoft.ServiceHosting.ServiceRuntime' and 
instead i am using Microsoft.WindowsAzure.Configuration. Might be because I am 
using latest version of Azure SDK from Oct-2012. So, i have decided to change 
the template. Following changes i have done in the template.

Change 1

I have copied the Microsoft.WindowsAzure.Configuration.dll from "C:\Program 
Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\ref\" to the reference 
folder of the framework

Change 2

In netTiers.cst i have changed following

if(IsConnectionStringAzure)

{

//SafeCopyFile(this.CodeTemplateInfo.DirectoryName + 
"\\References\\AzureSDKv1_0\\Microsoft.ServiceHosting.ServiceRuntime.dll", 
libPath + "\\Microsoft.ServiceHosting.ServiceRuntime.dll");

            SafeCopyFile(this.CodeTemplateInfo.DirectoryName + "\\References\\AzureSDKv1_0_200911\\Microsoft.WindowsAzure.Configuration.dll", libPath + "\\Microsoft.WindowsAzure.Configuration.dll");

}

Change 3

In DataRepository.cst i have changed following

<% if ( IsConnectionStringAzure ) { %>

//using Microsoft.ServiceHosting.ServiceRuntime;

using Microsoft.WindowsAzure;

<% } %>

And following

<% if ( IsConnectionStringAzure ) { %>

ConnectionStringSettingsCollection connectionStrings = new 
ConnectionStringSettingsCollection();

ConnectionStringSettings settings = new ConnectionStringSettings();

//settings.Name = "netTiersConnectionString";

//settings.ConnectionString = 
RoleManager.GetConfigurationSetting("netTiersConnectionString");

                    settings.Name = "<%=DALNameSpace%>.ConnectionString";

                    settings.ConnectionString = CloudConfigurationManager.GetSetting("<%=DALNameSpace%>.ConnectionString");

connectionStrings.Add(settings);

return connectionStrings;

<% } else { %>

Change 4

In cloud webrole's serviceconfiguration.cscfg file instead of 
netTiersConnectionString I have used same config name from my web.config (just 
got the feeling that it should match as mentioned in the provider details on 
web.config -- Sorry for my poor .net knowledge)

After above i have re-generated the solution and tested it working fine. 

I am also attaching the changed files. 

Original issue reported on code.google.com by pateljig...@gmail.com on 7 Dec 2012 at 10:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 7 Dec 2012 at 1:12