473,770 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collect ions.IDictionar y stateSaver)
{
//Get the parameter passed across in the CustomActionDat a
string strServerName = this.Context.Pa rameters["SNAME"];

if(strServerNam e == "")
throw new InstallExceptio n ("No arguments specified");

//Use reflection to find the location of the config file
Assembly Asm = Assembly.GetExe cutingAssembly( );
FileInfo fileInfo = new FileInfo(Asm.Lo cation + ".config");

if (!fileInfo.Exis ts)
throw new InstallExceptio n ("Missing Config file");

//Load the config file into the XML DOM.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa d (fileInfo.FullN ame);

//Finds the right node and change it to the new value
XmlNodeList nodelist = xmlDocument.Get ElementsByTagNa me ("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.Cou nt)
{
if(n.Name == "add")
{
if (n.Attributes["key"].Value == "SNAME")
{
n.Attributes["value"].Value = strServerName;
foundServerName = true;
}
}

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

if(!foundDataBa seName)
throw new InstallExceptio n ("config file did not contain a
servername section");

//Write out the new config file.
xmlDocument.Sav e (fileInfo.FullN ame);
}
thanks in advance.

---------------
Best regards
- Hans -
---------------
(Have fun programming with ... C#)
Nov 17 '05 #1
1 5354
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.Collect ions.IDictionar y stateSaver)
{
//Get the parameter passed across in the CustomActionDat a
string strServerName = this.Context.Pa rameters["SNAME"];

if(strServerNam e == "")
throw new InstallExceptio n ("No arguments specified");

//Use reflection to find the location of the config file
Assembly Asm = Assembly.GetExe cutingAssembly( );
FileInfo fileInfo = new FileInfo(Asm.Lo cation + ".config");

if (!fileInfo.Exis ts)
throw new InstallExceptio n ("Missing Config file");

//Load the config file into the XML DOM.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Loa d (fileInfo.FullN ame);

//Finds the right node and change it to the new value
XmlNodeList nodelist = xmlDocument.Get ElementsByTagNa me ("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.Cou nt)
{
if(n.Name == "add")
{
if (n.Attributes["key"].Value == "SNAME")
{
n.Attributes["value"].Value = strServerName;
foundServerName = true;
}
}

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

if(!foundDataBa seName)
throw new InstallExceptio n ("config file did not contain a
servername section");

//Write out the new config file.
xmlDocument.Sav e (fileInfo.FullN ame);
}
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
2292
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 of information, from where I offer a link users can click on. Let's say I have collected several strings and I have put these in an array and serialized that. $var='John Doe';
14
2975
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 been commented away to nothing during debugging, but the headers look like class Event { private: Object* recipient; int eventID;
5
3001
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 <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
0
1036
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 to add a "quite" mode that does not dislay any of the UI. I can hide the automatically created UI by calling my .msi as follows: msiexec /passive /i Hamsters.msi
3
2337
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 two modifications to the sample in the document...both are in the "Protected Sub AddDBTable" (towards the bottom). I've changed ' Creates the database.
1
1283
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 come with their own setup files. My plan was to put these in seperate directories on the distribution CD and use custom actions to run them after my main installation e.g. path1\setup1.exe parm1 parm2 path2\setup2.exe parm3 parm4 The setups...
13
9719
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 to set the Condition property of a custom action to determine if the currently running install is upgrading a previous installation and if so how? I'm also open to other methods of acheiving this functionality.
4
2215
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 SpecialFolder.ApplicationData (C:\Documents and Settings\Username\Application Data) ? Or, is there some way to get the ms installer to do this for you? Is there some way to use Application.UserAppDataPath to ease finding
4
2937
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 text and I can't find the error on why it isn't working. Any help is greatly appreciated. Here is the form
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.