468,310 Members | 1,433 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,310 developers. It's quick & easy.

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 5128
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Pjotr Wedersteers | last post: by
14 posts views Thread by Gregory L. Hansen | last post: by
5 posts views Thread by Craig Keightley | last post: by
1 post views Thread by rossu | last post: by
4 posts views Thread by - HAL9000 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.