Click here to Skip to main content
15,896,526 members

Need to know how to create registry key at setup installation in Windows application

Shanmugam Rathakrishnan asked:

Open original thread
i need to create registry key while installing my setup file. what i have to do....
Actually i created the installer class with the below code.

C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;


namespace StockManagement
{
    [RunInstaller(true)]
    public partial class Installer1 : Installer
    {
        public Installer1()
        {
            InitializeComponent();
        }
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
            int count = 10;
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\WIN32");
            key.SetValue("Sys", count, Microsoft.Win32.RegistryValueKind.String);
        }
    }
}



then i build it...
and i add it in my setup file under
custom actions-->install\

after build my setup file
when i install in my system it creates the registry key...
and works normally..
but when i install in other systems during installation.. i got the error

ERROR:1001 Unable to get the installer types in the c:\program files\stock management.exe assembly.--> Unable to load one are more of the requested types: Retrieve the loader exception property for more information..

how to solve this error...
Tags: .NET (.NET 3.5), Windows, Application, Setup, Registry

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900