none
Calling a function with WCF error RRS feed

  • Question

  • VS 2012 Professional

    OS: Windows 7 Ultimate 64 bit

    I am having a problem running a WCF function. 

     

    Message: IOException occurred "The specified registry key does not exist."

    HRResult 2

    StackTrace:   at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)

    Here is the code. The error occurs CarMaintenanceService.GetAllUsers().Rows.Count. Does anyone have any idea what's going on?

    Public Class winLogIn Dim CarMaintenanceService As New CarMaintenanceServiceReference.ServiceClient Public Sub New() ' This call is required by the designer. InitializeComponent() 'System.Net.ServicePointManager.DefaultConnectionLimit = 200 ' Add any initialization after the InitializeComponent() call. End Sub Private Sub winLogIn_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded If CarMaintenanceService.GetAllUsers().Rows.Count > 0 Then If CarMaintenanceService.GetAllUsers().Rows.Count > 0 Then For Each a In CarMaintenanceService.GetAllUsers().AsEnumerable() MessageBox.Show(a.UserName.ToString) Next End If End If End Sub Private Sub btnLogInExit_Click(sender As Object, e As RoutedEventArgs) Handles btnLogInExit.Click Me.Close() End Sub Private Sub btnLogIn_Click(sender As Object, e As RoutedEventArgs) Handles btnLogIn.Click End Sub End Class

    Saturday, August 3, 2013 7:20 PM

Answers

  • I uninstalled Visual Studio 2012 and reinstalled it and it fixed my problem. I really don't know what the problem was, but I solved it.
    • Marked as answer by achurchill Sunday, September 8, 2013 10:22 PM
    Sunday, September 8, 2013 10:21 PM

All replies

  • Hi achurchill,

    Check this one

    http://blog.alexonasp.net/post/2013/05/01/HttpClient-SystemIOIOException-e2809cThe-specified-registry-key-does-not-existe2809d.aspx

    Disclaimer: Do at your own risk, of course as it does change your system settings :)

    Thanks
    Subhendu

    Saturday, August 3, 2013 8:57 PM
  • I tried that unless I edit the registry wrong.  The LegacyWPADSupport part I put as the folder name and the dword:00000000 part I used as the Value data. Do I save it as a string value or key?

    64 bit

    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework]
    "LegacyWPADSupport"=dword:00000000

    I am not too familiar with editing the registry. I did save a copy before I edited it. Also do I have to restart the computer after any edit?

    Saturday, August 3, 2013 9:08 PM
  • Hi achurchill,

    Yes you have to restart your machine after doing the registry Change.

    Thanks
    Subhendu

    Saturday, August 3, 2013 9:19 PM
  • Still get the error. I get it here in the service reference in my presentation layer.

    <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)>  _
            Function CarMaintenanceServiceReference_IService_GetAllUsers(ByVal request As CarMaintenanceServiceReference.GetAllUsersRequest) As CarMaintenanceServiceReference.GetAllUsersResponse Implements CarMaintenanceServiceReference.IService.GetAllUsers
                Return MyBase.Channel.GetAllUsers(request)
            End Function


    • Edited by achurchill Saturday, August 3, 2013 9:51 PM
    Saturday, August 3, 2013 9:43 PM
  • Hi achurchill,

    I need to look at your code. Can you please post your code?

    Thanks
    Subhendu

    Sunday, August 4, 2013 3:11 AM
  • Imports DataAccessLayer.DataAccessDataManager
    
    Public Class Service
        Implements IService
    
    
        Public Sub New()
        End Sub
    
        Public Function GetAllUsers() As EnititesLayer.CarMaintenanceLogger.UsersDataTable Implements IService.GetAllUsers
            Return GetAllUsers()
        End Function
    
        Public Function SaveNewUser(newUser As EnititesLayer.User) As Boolean Implements IService.SaveNewUser
            Return SaveNewUser(newUser)
        End Function
    End Class

    Imports EnititesLayer
    
    ' NOTE: You can use the "Rename" command on the context menu to change the interface name "IService" in both code and config file together.
    
    <ServiceContract()>
    Public Interface IService
    
        <OperationContract()>
        Function GetAllUsers() As CarMaintenanceLogger.UsersDataTable
    
        <OperationContract()>
        Function SaveNewUser(newUser As User) As Boolean
    
      
    End Interface

    Imports EnititesLayer
    Imports EnititesLayer.CarMaintenanceLogger
    Imports System.Data.SqlClient
    
    
    Public Class DataAccessDataManager
    
        Dim sqlExpress As String = "\SQL2012"
        Dim machineName As String = "."
        Dim dataSource As String = machineName & sqlExpress
        Dim connString As String = String.Format("Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=master;Data Source={0}", dataSource)
        Private maintenanceLoggerDatabaseConnection As String = My.Settings.CarMaintenanceLoggerConnectionString
    
        Public Function GetAllUsers() As UsersDataTable
            Dim users As New UsersDataTable
            Dim sqlConn As New SqlConnection(connString)
            Dim userCommand As New SqlCommand()
            Dim sqlUsersAdapter As New CarMaintenanceLoggerTableAdapters.UsersTableAdapter
    
            Try
                'check the connection to see if its open. Open it if its not
                If sqlConn.State = ConnectionState.Closed Then
                    sqlConn.Open()
                End If
    
                'Fill the typed datatable 
                sqlUsersAdapter.Fill(users)
    
            Catch ex As InvalidOperationException
                Throw ex
            Catch ex As SqlException
                Throw ex
            Catch ex As Exception
                Throw ex
            Finally
                If Not sqlConn Is Nothing Then
                    sqlConn.Dispose()
                End If
    
                If Not sqlUsersAdapter Is Nothing Then
                    sqlUsersAdapter.Dispose()
                End If
    
                If Not userCommand Is Nothing Then
                    userCommand.Dispose()
                End If
            End Try
    
            'return typed datatable no matter what
            Return users
        End Function
    
    Public Function SaveNewUser(newUser As EnititesLayer.User) As Boolean
    
    End Function
    End Class

    Imports EnititesLayer
    
    Public Class winLogIn
    
        Dim sqlExpress As String = "\SQL2012"
        Dim machineName As String = "."
        Dim dataSource As String = machineName & sqlExpress
        Dim connString As String = String.Format("Persist Security Info=False;Integrated Security=SSPI;Initial Catalog=master;Data Source={0}", dataSource)
    
        Dim CarMaintenanceService As New CarMaintenanceServiceReference.ServiceClient
    
        Public Sub New()
            ' This call is required by the designer.
            InitializeComponent()
            'System.Net.ServicePointManager.DefaultConnectionLimit = 200
            ' Add any initialization after the InitializeComponent() call.
    
    
        End Sub
    
        Private Sub winLogIn_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
            'Dim usersTable As CarMaintenanceLogger.UsersDataTable
            'usersTable = CarMaintenanceService.GetAllUsers()
            cmbUserName.ItemsSource = CarMaintenanceService.GetAllUsers()
    
            If CarMaintenanceService.GetAllUsers().Rows.Count > 0 Then
                If CarMaintenanceService.GetAllUsers().Rows.Count > 0 Then
                    For Each a In CarMaintenanceService.GetAllUsers().AsEnumerable()
                        MessageBox.Show(a.UserName.ToString)
                    Next
                End If
            End If
        End Sub
    
        Private Sub btnLogInExit_Click(sender As Object, e As RoutedEventArgs) Handles btnLogInExit.Click
            Me.Close()
        End Sub
    
        Private Sub btnLogIn_Click(sender As Object, e As RoutedEventArgs) Handles btnLogIn.Click
    
        End Sub
    
        Private Sub btnCreateExit_Click(sender As Object, e As RoutedEventArgs) Handles btnCreateExit.Click
            Me.Close()
        End Sub
    
        Private Sub btnClearAll_Click(sender As Object, e As RoutedEventArgs) Handles btnClearAll.Click
            txtFirstName.Clear()
            txtLastName.Clear()
            txtUserName.Clear()
        End Sub
    
        Private Sub btnCreate_Click(sender As Object, e As RoutedEventArgs) Handles btnCreate.Click
    
        End Sub
    End Class
    

    <Window x:Class="winLogIn"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Log in/ New User" Height="205" Width="406" WindowStartupLocation="CenterScreen" MaxWidth="410" MaxHeight="205" MinWidth="410" MinHeight="205">
        <Grid>
            <TabControl>
                <TabItem x:Name="tabLogIn" Header="Log In">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="22*" />
                            <RowDefinition Height="74*" />
                            <RowDefinition Height="47*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="125*"/>
                            <ColumnDefinition Width="125*"/>
                            <ColumnDefinition Width="63*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="btnLogIn" Content="Log In" Grid.Column="1"  VerticalAlignment="Center" Margin="5,0" Grid.Row="2" Height="22"/>
                        <Button x:Name="btnLogInExit" Content="Exit" Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" Margin="5,0" Height="22"/>
                        <Label x:Name="lblUserNameLogin" Content="User Name" VerticalAlignment="Center" Margin="5,24" HorizontalContentAlignment="Center" Grid.Row="1" Height="26"/>
                        <ComboBox x:Name="cmbUserName"  Grid.Column="1" Margin="5,0" VerticalAlignment="Center" Grid.ColumnSpan="2" Grid.Row="1"/>
                    </Grid>
                </TabItem>
                <TabItem x:Name="tabCreateUser" Header="Create User">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="256*"/>
                            <ColumnDefinition Width="65*"/>
                        </Grid.ColumnDefinitions>
                        <Button x:Name="btnCreate" Content="Create" Grid.Column="2"  VerticalAlignment="Center" Margin="5,0"/>
                        <Button x:Name="btnCreateExit" Content="Exit" Grid.Column="2" Grid.Row="1" VerticalAlignment="Center" Margin="5,0"/>
                        <Button x:Name="btnClearAll" Content="Clear All" Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" Margin="5,0"/>
                        <TextBox x:Name="txtUserName" Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5,0"/>
                        <TextBox x:Name="txtLastName" Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5,0"/>
                        <Label x:Name="lblCreateUserName" Content="User Name" VerticalAlignment="Center" Margin="5,0" HorizontalContentAlignment="Center"/>
                        <Label x:Name="lblCreateFirstName" Content="First Name"  Grid.Row="1" VerticalAlignment="Center" Margin="5,0" HorizontalContentAlignment="Center"/>
                        <Label x:Name="lblCreateLastName" Content="Last Name"  Grid.Row="2" VerticalAlignment="Center" Margin="5,0" HorizontalContentAlignment="Center"/>
                        <TextBox x:Name="txtFirstName" Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Center" Margin="5,0"/>
    
                    </Grid>
                </TabItem>
            </TabControl>
    
        </Grid>
    </Window>

    <%@ ServiceHost Language="VB" Debug="true" Service="Service" CodeBehind="~/App_Code/Service.vb" %>

    <?xml version="1.0"?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="false" strict="false" explicit="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
        <pages>
          <namespaces>
            <add namespace="System.Runtime.Serialization" />
            <add namespace="System.ServiceModel" />
            <add namespace="System.ServiceModel.Web" />
          </namespaces>
        </pages>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>
    
    </configuration>
    

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
        </startup>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService" />
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:50728/Service.svc" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_IService" contract="CarMaintenanceServiceReference.IService"
                    name="BasicHttpBinding_IService" />
            </client>
        </system.serviceModel>
    </configuration>

    Let me know if you need anything else. Thank you for your help.
    Sunday, August 4, 2013 11:38 PM
  • Wait, I didn't find the error. I get an error when I call a WCF service. Doesn't matter what function I call, the error is still there. I don't know if its a configuration or VS 2012. I cant call anything in WCF.

    An unhandled exception of type 'System.StackOverflowException' occurred in CarMaintenanceFuelLogger.dll

    Friday, August 30, 2013 12:15 AM
  • I uninstalled Visual Studio 2012 and reinstalled it and it fixed my problem. I really don't know what the problem was, but I solved it.
    • Marked as answer by achurchill Sunday, September 8, 2013 10:22 PM
    Sunday, September 8, 2013 10:21 PM
  • datalogic 

    class 1.vb

    Public Class Class1
        Public Function GetMachineList() As List(Of WcfService1.Machine) class is not recognizing , but other functions are working fine 
            Dim oConn As New Informix("xxxxx;")
            Dim machines As New List(Of Machine)()
            Dim strSql As String = "SELECT k_koneno AS ma_machineid,k_paikka AS ma_placenumber,k_malli AS ma_model,k_tyyppi AS ma_type,k_versio AS ma_version FROM kone"


            Try
                oConn.OpenDB()
                Dim reader = oConn.SelectQueryIntoReader(strSql)
                If reader IsNot Nothing Then
                    While reader.Read()
                        Dim machine As New Machine()
                        machine.ma_machineid = reader.GetString(0)
                        machine.ma_placenumber = reader.GetString(1)
                        machine.ma_model = reader.GetString(2)
                        machine.ma_type = reader.GetString(3)
                        machine.ma_version = reader.GetString(4)
                        machines.Add(machine)
                    End While
                End If
                Return machines

            Catch ex As Exception
                Throw New System.Exception(ex.Message)
            Finally
                oConn.CloseDB()
            End Try

        End Function
        Public Function GetLastName() As String

            Dim oConn As New Informix("xxxxx")

            Dim oo As String

            Try
                oConn.OpenDB()
                oo = oConn.GetFirstValue("select p_fornamn from person where p_efternamn = 'JATOI'").ToString
                Return oo.ToString

            Catch ex As Exception
                Throw New System.Exception(ex.Message)
            Finally
                oConn.CloseDB()
            End Try


        End Function

        Public Function GetPersonsTable() As DataSet
            Dim oConn As New Informix("xxx")

            Dim daTable As New DataTable
            Dim dsTable As New DataSet


            Try
                oConn.OpenDB()


                Dim person = oConn.SelectQueryIntoTable("SELECT k_koneno AS ma_machineid, k_paikka AS ma_placenumber, k_malli AS ma_model,k_tyyppi AS ma_type, k_versio AS ma_version FROM kone WHERE k_paikka = 18 AND k_autmod = 'A'", daTable)

                dsTable.Tables.Add(daTable)
                Return dsTable

            Catch ex As Exception
                Throw New System.Exception(ex.Message)

            Finally
                oConn.CloseDB()

            End Try



        End Function

        Public Function GetPersonsTest() As DataSet
            Dim oConn As New Informix("xxxxx")

            Dim daTable As New DataTable
            Dim dsTable As New DataSet


            Try
                oConn.OpenDB()


                Dim person = oConn.SelectQueryIntoTable("SELECT * from person", daTable)

                dsTable.Tables.Add(daTable)
                Return dsTable

            Catch ex As Exception
                Throw New System.Exception(ex.Message)

            Finally
                oConn.CloseDB()

            End Try



        End Function
    End Class

    wcf service1

    Iservice1.Vb

        

    Imports System.Web.Script.Services

    ' NOTE: You can use the "Rename" command on the context menu to change the interface name "IService1" in both code and config file together.
    <ServiceContract()>
    Public Interface IService1

        <OperationContract()>
             <WebInvoke(Method:="Get",
                         ResponseFormat:=WebMessageFormat.Json,
                BodyStyle:=WebMessageBodyStyle.Wrapped,
                UriTemplate:="GetDataJSON")> _
        Function GetData(ByVal value As Integer) As String


        <OperationContract()>
        Function GetPersonTable() As DataSet

        <OperationContract()>
        Function GetPersonTest() As DataSet

        <OperationContract()>
        Function GetMachineList() As List(Of Machine)




        <OperationContract()>
        Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType

        ' TODO: Add your service operations here

    End Interface

    ' Use a data contract as illustrated in the sample below to add composite types to service operations.

    <DataContract()>
    Public Class CompositeType

        <DataMember()>
        Public Property BoolValue() As Boolean

        <DataMember()>
        Public Property StringValue() As String

    End Class

    <DataContract()>
    Public Class Machine
        Public Property MachineId() As String
            Get
                Return mma_machineid
            End Get

            Set(ByVal value As String)
                mma_machineid = value

            End Set
        End Property
        Private mma_machineid As String


        Public Property MachinePlaceNumber() As String
            Get
                Return mma_placenumber
            End Get
            Set(ByVal value As String)
                mma_placenumber = value
            End Set
        End Property
        Private mma_placenumber As String

        Public Property MachineModel() As String
            Get
                Return mma_model
            End Get
            Set(ByVal value As String)
                mma_model = value
            End Set
        End Property
        Private mma_model As String

        Public Property MachineType() As String
            Get
                Return mma_type
            End Get
            Set(ByVal value As String)
                mma_type = value
            End Set
        End Property
        Private mma_type As String
        Public Property MachineVersion() As String
            Get
                Return mma_version
            End Get
            Set(ByVal value As String)
                mma_version = value
            End Set
        End Property
        Private mma_version As String
    End Class

    Service1.Vb

    Public Class Service1
        Implements IService1

        Public Sub New()
        End Sub

        Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
         
            Dim oDL As New Datalogic.Class1
            Return oDL.GetLastName
            

        End Function


        Public Function GetPersonTable() As DataSet Implements IService1.GetPersonTable
       
            Dim oDL As New Datalogic.Class1
            Return oDL.GetPersonsTable


        End Function

        Public Function GetPersonTest() As DataSet Implements IService1.GetPersonTest
        
            Dim oDL As New Datalogic.Class1
            Return oDL.GetPersonsTest


        End Function

        Public Function GetMachineList() As List(Of Machine) Implements IService1.GetMachineList

      
      
        Dim oDL As New Datalogic.Class1
            Return oDL.GetMachineList


        End Function






        Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements IService1.GetDataUsingDataContract
            If composite Is Nothing Then
                Throw New ArgumentNullException("composite")
            End If
            If composite.BoolValue Then
                composite.StringValue &= "Suffix"
            End If
            Return composite
        End Function

    End Class

    ALL OTHER FUNCIONS ARE WORKING FINE BUT ONLY THE Public Function GetMachineList() As List(Of WcfService1.Machine) class SHOWING ERROR NOW PLEASE HELP i spent days on it.

    and i have made reference other functions are working fine but machine list is not working fine

    Wednesday, August 6, 2014 7:46 AM