I wrote a tiny code just to create an SQL database inside a Rhinocommon plugin.
It works quite fine with windows forms Application, but for the same code and the same process, it show null reference exception when it is a RhinoCommon SDK.
This line below give null reference exception.
I have attached the zip file as a small/tiny project in visual Studio 2010 c# dot net
If you are getting a NullReferenceException, it is probably the call to ConfigurationManager.ConnectionStrings. Try directly embedding that string in your code to see if that works.
Dear Steve,
Thanks for the reply.
I tried in several ways. nothing works.
Is there any setting I need to do when it is Rhino plugin ?
Because it kind of work in different ways , when it is just a Windows Forms Application.
This string below shows syntax error, when I have put it directly.
“Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True”
or if I put it in this way below, still the plugin hang in Rhino. But it shows compile succeeded.
.\SQLEXPRESS;AttachDbFilename=“C:\Users\John\documents\visual studio 2010\Projects\SQL_TEST_02\SQL_TEST_02\Database1.mdf”;Integrated Security=True;User Instance=True
There is no difference when between a stand-alone application and a plug-in in this context. It is probably your connection string. I can’t remember exactly how to read those, but it looks like there are some paths involved in there. Like, what is DataDirectory.
So I tried full path, in that case Rhino Hang.
.\SQLEXPRESS;AttachDbFilename=“C:\Users\John\documents\visual studio
2010\Projects\SQL_TEST_02\SQL_TEST_02\Database1.mdf”;Integrated
Security=True;User Instance=True
DataDirectory is "C:\Users\John\documents\visual studio 2010\Projects\SQL_TEST_02\SQL_TEST_02\Database1.mdf
eventually the whole string is as below
.\SQLEXPRESS;AttachDbFilename=“C:\Users\John\documents\visual studio
2010\Projects\SQL_TEST_02\SQL_TEST_02\Database1.mdf”;Integrated
Security=True;User Instance=True
No. just it stuck with a null reference exception.
Do I need to change any Configuration information for Rhino Common and SQL.
WebConfig or AppConfig settings I mean.
Yes, I doubt that will work when run in a plug-in which is why I suggested directly embedding a connection string in your code instead of using ConfigurationManger.
Are you sure you are referencing everything you should in the plugin project? Imported everything? Right .NET versions and all? Initializing everything after declaring?
Maybe something from the forms application has fallen on the way to the plugin…