Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:44:47+00:00 2026-05-27T16:44:47+00:00

(sorry for my english), now it’s my first time using WCF, so my question

  • 0

(sorry for my english), now it’s my first time using WCF, so my question can be very simple) so: there is an example from MSDN: 1 solution – 2 projects: service and client like this: service:

<ServiceContract()> _
    Public Interface ICalculator
        <OperationContract()> _
        Function Openserv(ByVal n1 As Integer) As Boolean
    End Interface
Public Class Service
    Implements ICalculator

    Dim servicehost As System.ServiceModel.ServiceHost

    Private Sub Service_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim baseAddress As Uri = New Uri("http://localhost:8000/ServiceModelSamples/service")
        Dim address As String = "net.pipe://localhost/ServiceModelSamples/service"
        servicehost = New System.ServiceModel.ServiceHost(GetType(Service), baseAddress)
        Dim binding As System.ServiceModel.NetNamedPipeBinding = New System.ServiceModel.NetNamedPipeBinding(System.ServiceModel.NetNamedPipeSecurityMode.Transport)
        binding.CloseTimeout = New TimeSpan(0, 1, 0)
        binding.Name = "Binding1"
        binding.OpenTimeout = New TimeSpan(0, 1, 0)
        binding.ReceiveTimeout = New TimeSpan(0, 10, 0)
        binding.SendTimeout = New TimeSpan(0, 10, 0)
        binding.TransactionFlow = False
        binding.TransactionProtocol = System.ServiceModel.TransactionProtocol.OleTransactions
        binding.TransferMode = System.ServiceModel.TransferMode.Buffered
        binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard
        binding.MaxBufferPoolSize = 524288
        binding.MaxBufferSize = 65536
        binding.MaxConnections = 10
        binding.MaxReceivedMessageSize = 65536
        servicehost.AddServiceEndpoint(GetType(ICalculator), binding, address)
        Dim smb As System.ServiceModel.Description.ServiceMetadataBehavior = New System.ServiceModel.Description.ServiceMetadataBehavior
        smb.HttpGetEnabled = True
        servicehost.Description.Behaviors.Add(smb)
        servicehost.Open()
    End Sub
        Public Function Openserv(ByVal n1 As Integer) As Boolean _
    Implements ICalculator.Openserv
    If n1 > 0 Then
        filename &= n1 & ":"
    End If
    Dim result As Boolean = True
    Return result
End Function
End Class

client:

<System.ServiceModel.ServiceContract()> _
    Public Interface ICalculatorClient
        <System.ServiceModel.OperationContract()> _
        Function Openserv(ByVal n1 As Integer) As Boolean
    End Interface
    Partial Public Class CalculatorClient
        Inherits System.ServiceModel.ClientBase(Of ICalculatorClient)
        Implements ICalculatorClient

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal endpointConfigurationName As String)
            MyBase.New(endpointConfigurationName)
        End Sub

        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub

        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub

        Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(binding, remoteAddress)
        End Sub

        Public Function OpenServ(ByVal n1 As Integer) As Boolean Implements ICalculatorClient.Openserv
            Return MyBase.Channel.Openserv(n1)
        End Function

    End Class
Public Class Client

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim bld As New System.ServiceModel.NetNamedPipeBinding
        Dim epa As New System.ServiceModel.EndpointAddress("net.pipe://localhost/servicemodelsamples/service")
        Dim client As New CalculatorClient(bld, epa)
        Dim value1 As Integer = 33
        Dim result As Boolean = client.OpenServ(value1)
        client.Close()
        MessageBox.Show("Открыто в основном приложении")

    End Sub
End Class

now the question: how can i do this example when the client is the codedom assembly, generating by application-service? something like that: add a button to main form of application-service and add this text:

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        cr_text()
        cr_app()
    End Sub
    Private Sub cr_text()
        str_tb = "Imports System" & Chr(13) & Chr(10) & _
"Imports System.CodeDom" & Chr(13) & Chr(10) & _
"Imports System.CodeDom.Compiler" & Chr(13) & Chr(10) & _
"Imports System.Collections" & Chr(13) & Chr(10) & _
"Imports System.ComponentModel" & Chr(13) & Chr(10) & _
"Imports System.Diagnostics" & Chr(13) & Chr(10) & _
"Imports System.Windows.Forms" & Chr(13) & Chr(10) & _
"Imports System.Data" & Chr(13) & Chr(10) & _
"Imports System.Windows" & Chr(13) & Chr(10) & _
"Imports System.Data.SqlClient" & Chr(13) & Chr(10) & _
"Imports Microsoft.VisualBasic" & Chr(13) & Chr(10) & _
"Imports System.IO" & Chr(13) & Chr(10) & _
"Imports System.Drawing" & Chr(13) & Chr(10) & _
"Public Class MainClass" & Chr(13) & Chr(10) & _
"Public Shared Sub Main()" & Chr(13) & Chr(10) & _
"Dim tf As New test34" & Chr(13) & Chr(10) & _
"tf.show()" & Chr(13) & Chr(10) & _
"End Sub" & Chr(13) & Chr(10) & _
"End Class" & Chr(13) & Chr(10) & _
   "     <System.ServiceModel.ServiceContract()> _" & Chr(13) & Chr(10) & _
"    Public Interface ICalculator" & Chr(13) & Chr(10) & _
"        <System.ServiceModel.OperationContract()> _" & Chr(13) & Chr(10) & _
"        Function Openserv(ByVal n1 As Integer) As Boolean" & Chr(13) & Chr(10) & _
"    End Interface" & Chr(13) & Chr(10) & _
"    Partial Public Class CalculatorClient" & Chr(13) & Chr(10) & _
"        Inherits System.ServiceModel.ClientBase(Of ICalculator)" & Chr(13) & Chr(10) & _
"        Implements ICalculator" & Chr(13) & Chr(10) & _
"        Public Sub New()" & Chr(13) & Chr(10) & _
"            MyBase.New()" & Chr(13) & Chr(10) & _
"        End Sub" & Chr(13) & Chr(10) & _
"        Public Sub New(ByVal endpointConfigurationName As String)" & Chr(13) & Chr(10) & _
"            MyBase.New(endpointConfigurationName)" & Chr(13) & Chr(10) & _
"        End Sub" & Chr(13) & Chr(10) & _
"        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)" & Chr(13) & Chr(10) & _
"            MyBase.New(endpointConfigurationName, remoteAddress)" & Chr(13) & Chr(10) & _
"        End Sub" & Chr(13) & Chr(10) & _
"        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)" & Chr(13) & Chr(10) & _
"            MyBase.New(endpointConfigurationName, remoteAddress)" & Chr(13) & Chr(10) & _
"        End Sub" & Chr(13) & Chr(10) & _
"        Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)" & Chr(13) & Chr(10) & _
"            MyBase.New(binding, remoteAddress)" & Chr(13) & Chr(10) & _
"        End Sub" & Chr(13) & Chr(10) & _
"        Public Function OpenServ(ByVal n1 As Integer) As Boolean Implements ICalculator.Openserv" & Chr(13) & Chr(10) & _
"            Return MyBase.Channel.Openserv(n1)" & Chr(13) & Chr(10) & _
"        End Function" & Chr(13) & Chr(10) & _
"    End Class" & Chr(13) & Chr(10) & _
"        <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _" & Chr(13) & Chr(10) & _
"Partial Class test34" & Chr(13) & Chr(10) & _
"    Inherits System.Windows.Forms.Form" & Chr(13) & Chr(10) & _
"    <System.Diagnostics.DebuggerNonUserCode()> _" & Chr(13) & Chr(10) & _
"    Protected Overrides Sub Dispose(ByVal disposing As Boolean)" & Chr(13) & Chr(10) & _
"        Try" & Chr(13) & Chr(10) & _
"        If Disposing AndAlso components IsNot Nothing Then" & Chr(13) & Chr(10) & _
"        components.Dispose()" & Chr(13) & Chr(10) & _
"        End If" & Chr(13) & Chr(10) & _
"        Finally" & Chr(13) & Chr(10) & _
"        MyBase.Dispose(Disposing)" & Chr(13) & Chr(10) & _
"        End Try" & Chr(13) & Chr(10) & _
"    End Sub" & Chr(13) & Chr(10) & _
"        Private components As System.ComponentModel.IContainer" & Chr(13) & Chr(10) & _
"    <System.Diagnostics.DebuggerStepThrough()> _" & Chr(13) & Chr(10) & _
"    Private Sub InitializeComponent()" & Chr(13) & Chr(10) & _
"        Me.Button1 = New System.Windows.Forms.Button" & Chr(13) & Chr(10) & _
"        Me.Button3 = New System.Windows.Forms.TextBox" & Chr(13) & Chr(10) & _
"        Me.SuspendLayout()" & Chr(13) & Chr(10) & _
"        Me.Button1.Location = New System.Drawing.Point(114, 40)" & Chr(13) & Chr(10) & _
"        Me.Button1.Name = " & Chr(34) & "Button1" & Chr(34) & "" & Chr(13) & Chr(10) & _
"        Me.Button1.Size = New System.Drawing.Size(231, 39)" & Chr(13) & Chr(10) & _
"        Me.Button1.TabIndex = 0" & Chr(13) & Chr(10) & _
"        Me.Button1.Text = " & Chr(34) & "Button1" & Chr(34) & "" & Chr(13) & Chr(10) & _
"        Me.Button1.UseVisualStyleBackColor = True" & Chr(13) & Chr(10) & _
"        Me.Button3.Location = New System.Drawing.Point(114, 90)" & Chr(13) & Chr(10) & _
"        Me.Button3.Name = " & Chr(34) & "Button3" & Chr(34) & "" & Chr(13) & Chr(10) & _
"        Me.Button3.Size = New System.Drawing.Size(231, 39)" & Chr(13) & Chr(10) & _
"        Me.Button3.TabIndex = 2" & Chr(13) & Chr(10) & _
"        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)" & Chr(13) & Chr(10) & _
"        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font" & Chr(13) & Chr(10) & _
"        Me.ClientSize = New System.Drawing.Size(465, 133)" & Chr(13) & Chr(10) & _
"        Me.Controls.Add(Me.Button1)" & Chr(13) & Chr(10) & _
"        Me.Controls.Add(Me.Button3)" & Chr(13) & Chr(10) & _
"        Me.Name = " & Chr(34) & "test" & Chr(34) & "" & Chr(13) & Chr(10) & _
"        Me.Text = " & Chr(34) & "test" & Chr(34) & "" & Chr(13) & Chr(10) & _
"        Me.ResumeLayout(False)" & Chr(13) & Chr(10) & _
"    End Sub" & Chr(13) & Chr(10) & _
"        Friend WithEvents Button1 As System.Windows.Forms.Button" & Chr(13) & Chr(10) & _
"        Friend WithEvents Button3 As System.Windows.Forms.TextBox" & Chr(13) & Chr(10) & _
"End Class" & Chr(13) & Chr(10) & _
"Public Class test34" & Chr(13) & Chr(10) & _
"    Dim str_tb As String" & Chr(13) & Chr(10) & _
"    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click" & Chr(13) & Chr(10) & _
"        Dim bld As New System.ServiceModel.NetNamedPipeBinding" & Chr(13) & Chr(10) & _
"        Dim epa As New System.ServiceModel.EndpointAddress(" & Chr(34) & "net.pipe://localhost/servicemodelsamples/service" & Chr(34) & ")" & Chr(13) & Chr(10) & _
"        Dim client As New CalculatorClient(bld, epa)" & Chr(13) & Chr(10) & _
"        Dim value1 As Integer = Button3.Text" & Chr(13) & Chr(10) & _
"        Dim result As Boolean = client.OpenServ(value1)" & Chr(13) & Chr(10) & _
"        client.Close()" & Chr(13) & Chr(10) & _
"        MessageBox.Show(" & Chr(34) & "Открыто в основном приложении" & Chr(34) & ")" & Chr(13) & Chr(10) & _
"    End Sub" & Chr(13) & Chr(10) & _
"End Class"

    End Sub
    Private Shared Sub cr_app()
        Dim objCodeCompiler As System.CodeDom.Compiler.CodeDomProvider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("VB")
        Dim objCompilerParameters As New System.CodeDom.Compiler.CompilerParameters()
        objCompilerParameters.ReferencedAssemblies.Add("mscorlib.dll")
        objCompilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
        objCompilerParameters.ReferencedAssemblies.Add("System.dll")
        objCompilerParameters.ReferencedAssemblies.Add("C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.ServiceModel.dll")
        objCompilerParameters.ReferencedAssemblies.Add("System.Xml.dll")
        objCompilerParameters.ReferencedAssemblies.Add("System.Data.dll")
        objCompilerParameters.ReferencedAssemblies.Add("System.Drawing.dll")
        objCompilerParameters.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll")
        objCompilerParameters.CompilerOptions = "/target:winexe"
        objCompilerParameters.GenerateExecutable = True
        objCompilerParameters.GenerateInMemory = True
        objCompilerParameters.IncludeDebugInformation = False
        Dim objCompileResults As System.CodeDom.Compiler.CompilerResults = objCodeCompiler.CompileAssemblyFromSource(objCompilerParameters, str_tb)
        If objCompileResults.Errors.HasErrors Then
            MessageBox.Show(String.Format("Error: Line>{0}, {1} # {2}", objCompileResults.Errors(0).Line, objCompileResults.Errors(0).ErrorText, objCompileResults.Errors(0).ErrorNumber))
            Return
        End If
        Dim objAssembly As System.Reflection.Assembly = objCompileResults.CompiledAssembly
        Dim objTheClass As Object = objAssembly.CreateInstance("MainClass")
        If objTheClass Is Nothing Then
            MsgBox("Can't load class...")
            Exit Sub
        End If
        Try
            objTheClass.GetType.InvokeMember("Main", System.Reflection.BindingFlags.InvokeMethod, _
            Nothing, objTheClass, Nothing)
        Catch ex As Exception
            MsgBox("Error:" & ex.Message)
        End Try
    End Sub

but the client make an exception “timeout expired”… how can I make it work? maybe use something else instead netpipebinding? I can rewrite this on C#, if it will help.
The major question: how to call from generated assembly another sub of generates it class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:44:47+00:00Added an answer on May 27, 2026 at 4:44 pm

    it was a threading))) if run the assembly in the other thread it works great

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, I am really sorry for my poor english. Now when I use Ext.List
First, Sorry for my English - I'm from Austria. Hy guys! I made a
It is the first time I ask a question on this forum. Sorry if
first im so sorry with my english, im new with Django, im from php
Ok First have all i'm sorry for my poor english :) Now for my
(Sorry for my english) First: I have an application created using C++ (this is
Sorry for bad English :( Suppose i can preliminary organize recipes and ingredients data
At first sorry my bad English. I want define routing for this url: For
at first sorry my bad English I want load model in my plugin controller
Firstly, sorry for my English (I'm from China). By reading this article( how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.