473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

having problem with passing data to custom action

Hi!

I have problem with passing data to custom action. I don't know what wrong
I'm doing. I'm trying to follow the steps in the walkthrough: "Passing Data
to a Custom Action"

http://msdn.microsoft.com/library/de...stomaction.asp

The error I recieve is:
"The savedSate dictionary does not contain the expected values and might
have been corrupt."

The code I'm using in the installer class is as follow:
public override void Install (System.Collections.IDictionary stateSaver)
{
//Get the parameter passed across in the CustomActionData
string strServerName = this.Context.Parameters["SNAME"];

if(strServerName == "")
throw new InstallException ("No arguments specified");

//Use reflection to find the location of the config file
Assembly Asm = Assembly.GetExecutingAssembly();
FileInfo fileInfo = new FileInfo(Asm.Location + ".config");

if (!fileInfo.Exists)
throw new InstallException ("Missing Config file");

//Load the config file into the XML DOM.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load (fileInfo.FullName);

//Finds the right node and change it to the new value
XmlNodeList nodelist = xmlDocument.GetElementsByTagName ("appSettings");

bool foundServerName = false;

for (int i = 0; i < nodelist.Count; i++)
{
int y = 0;
XmlNode n = nodelist[i].FirstChild;
while (y < nodelist[i].ChildNodes.Count)
{
if(n.Name == "add")
{
if (n.Attributes["key"].Value == "SNAME")
{
n.Attributes["value"].Value = strServerName;
foundServerName = true;
}
}

n = n.NextSibling;
y++;
}
}

if(!foundDataBaseName)
throw new InstallException ("config file did not contain a
servername section");

//Write out the new config file.
xmlDocument.Save (fileInfo.FullName);
}
thanks in advance.

---------------
Best regards
- Hans -
---------------
(Have fun programming with ... C#)
Nov 17 '05 #1
1 5335
I've solved the problem... :-)

I've forgot...

base.inastall (savedState);
---------------
Best regards
- Hans -
---------------
(Have fun programming with ... C#)
"Hans [DiaGraphIT]" wrote:
Hi!

I have problem with passing data to custom action. I don't know what wrong
I'm doing. I'm trying to follow the steps in the walkthrough: "Passing Data
to a Custom Action"

http://msdn.microsoft.com/library/de...stomaction.asp

The error I recieve is:
"The savedSate dictionary does not contain the expected values and might
have been corrupt."

The code I'm using in the installer class is as follow:
public override void Install (System.Collections.IDictionary stateSaver)
{
//Get the parameter passed across in the CustomActionData
string strServerName = this.Context.Parameters["SNAME"];

if(strServerName == "")
throw new InstallException ("No arguments specified");

//Use reflection to find the location of the config file
Assembly Asm = Assembly.GetExecutingAssembly();
FileInfo fileInfo = new FileInfo(Asm.Location + ".config");

if (!fileInfo.Exists)
throw new InstallException ("Missing Config file");

//Load the config file into the XML DOM.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load (fileInfo.FullName);

//Finds the right node and change it to the new value
XmlNodeList nodelist = xmlDocument.GetElementsByTagName ("appSettings");

bool foundServerName = false;

for (int i = 0; i < nodelist.Count; i++)
{
int y = 0;
XmlNode n = nodelist[i].FirstChild;
while (y < nodelist[i].ChildNodes.Count)
{
if(n.Name == "add")
{
if (n.Attributes["key"].Value == "SNAME")
{
n.Attributes["value"].Value = strServerName;
foundServerName = true;
}
}

n = n.NextSibling;
y++;
}
}

if(!foundDataBaseName)
throw new InstallException ("config file did not contain a
servername section");

//Write out the new config file.
xmlDocument.Save (fileInfo.FullName);
}
thanks in advance.

---------------
Best regards
- Hans -
---------------
(Have fun programming with ... C#)

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pjotr Wedersteers | last post by:
Hello again, I have now several consecutive forms in my site which nicely pass variables in POST, so they won't show up in the header. Now I have a page people reach after submitting all kinds...
14
by: Gregory L. Hansen | last post by:
I can't seem to make a queue of objects, using the STL queue. I'm trying to make a little event manager, and I just want someplace to store events. The method definitions for EventManager have...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
0
by: krose | last post by:
I have created an Installer using the "Setup Wizard" in Visual Studio. I've added a custom action to this as a seperate DLL written in C#. Everything is working and going well. But now I want...
3
by: DC Gringo | last post by:
Hi, I'm trying to use a custom action to modify a database (rather than create one) using the VS.NET '03's help example called "Custom Action to Create Database During Installation". I've made...
1
by: rossu | last post by:
I need to deploy a couple of sets of third party drivers with my application and the customer would like the whole thing to run automatically when they put in the installation CD. These drivers...
13
by: Matt F | last post by:
I have a deployment project that I'm setting up. I need to perform a different custom action based on whether this is a first time install or an update. Does anyone have any idea if it's possible...
4
by: - HAL9000 | last post by:
When un-installing an application... Is it normal practice to write a special program that erases all the files and folders for all the users of an application that reads and writes to...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.