vb.net

System.Net.IPAddress returning weird addresses

穿精又带淫゛_ 提交于 2021-02-10 03:50:31
问题 I am writing a (rather simple :) networking application, and am testing it using localhost:27488 ( 127.0.0.1:27488 ). I am using a System.Net.Sockets.TcpClient for the connection, which takes a System.Net.IPAddress to specify the host... the only thing is, I can't figure out how to initialize the class with the right IP address. I went over the MSDN docs and it says it takes either a Byte(4) or an Int64 ( long ) for the address. The probelm is, when I initialize the IPAddress like this: Dim

System.Net.IPAddress returning weird addresses

旧巷老猫 提交于 2021-02-10 03:50:24
问题 I am writing a (rather simple :) networking application, and am testing it using localhost:27488 ( 127.0.0.1:27488 ). I am using a System.Net.Sockets.TcpClient for the connection, which takes a System.Net.IPAddress to specify the host... the only thing is, I can't figure out how to initialize the class with the right IP address. I went over the MSDN docs and it says it takes either a Byte(4) or an Int64 ( long ) for the address. The probelm is, when I initialize the IPAddress like this: Dim

Problems Self-Hosting ASP.NET Web API in a Windows Service Application

好久不见. 提交于 2021-02-10 03:20:49
问题 I've seen some articles on the web describing how to self host an ASP.NET Web API in a Windows service application (see here and here). I've written some simple code in VB.NET to start the self host when the service starts and stop it when the service stops, like so: Protected Overrides Sub OnStart(ByVal args() As String) Try ' init a new self host configuration using the base address _config = New HttpSelfHostConfiguration(New Uri("http://localhost:8080")) ' map the URLs into the config

can i use a keyword as a propertyname in vb .net?

杀马特。学长 韩版系。学妹 提交于 2021-02-09 17:55:01
问题 I have to serialize/deserialize a class into a JSON string/and return. The JSON Strinig must contain the "error" string (like: {error:"something strange occoured", id:23, result:"xxxxx"}), which specifies the occoured error. How can i implement a class like: Public Class JsonResponse Public result As JsonResult Public error As String Public id As Integer End Class If i do this, the word 'error' is invalid. Thanks 回答1: Surround it with square brackets Public Class JsonResponse Public result As

How do I get an event to fire as soon as an object's constructor has finished?

邮差的信 提交于 2021-02-09 12:18:00
问题 Research tells me that raising an event from the constructor itself is not feasible as the object may not be fully initialised... so where can I fire an event from as soon as the constructor has fired? 回答1: One thing you can do is add a method to handle additional post ctor tasks: Friend Class FooBar Public Sub New ' your code here End Sub Public Sub Create ' do anything you want End Sub End Class Elsewhere: Friend WithEvents Foo As Foobar ' ... Foo = New FooBar ' Foo doesnt exist until ctor

How do I get an event to fire as soon as an object's constructor has finished?

爱⌒轻易说出口 提交于 2021-02-09 12:15:34
问题 Research tells me that raising an event from the constructor itself is not feasible as the object may not be fully initialised... so where can I fire an event from as soon as the constructor has fired? 回答1: One thing you can do is add a method to handle additional post ctor tasks: Friend Class FooBar Public Sub New ' your code here End Sub Public Sub Create ' do anything you want End Sub End Class Elsewhere: Friend WithEvents Foo As Foobar ' ... Foo = New FooBar ' Foo doesnt exist until ctor

How do I get an event to fire as soon as an object's constructor has finished?

无人久伴 提交于 2021-02-09 12:15:34
问题 Research tells me that raising an event from the constructor itself is not feasible as the object may not be fully initialised... so where can I fire an event from as soon as the constructor has fired? 回答1: One thing you can do is add a method to handle additional post ctor tasks: Friend Class FooBar Public Sub New ' your code here End Sub Public Sub Create ' do anything you want End Sub End Class Elsewhere: Friend WithEvents Foo As Foobar ' ... Foo = New FooBar ' Foo doesnt exist until ctor

How do I get an event to fire as soon as an object's constructor has finished?

和自甴很熟 提交于 2021-02-09 12:15:10
问题 Research tells me that raising an event from the constructor itself is not feasible as the object may not be fully initialised... so where can I fire an event from as soon as the constructor has fired? 回答1: One thing you can do is add a method to handle additional post ctor tasks: Friend Class FooBar Public Sub New ' your code here End Sub Public Sub Create ' do anything you want End Sub End Class Elsewhere: Friend WithEvents Foo As Foobar ' ... Foo = New FooBar ' Foo doesnt exist until ctor

Deserialize JSON which can have different objects under same property name

最后都变了- 提交于 2021-02-09 11:12:12
问题 I'm using JSON.NET to deserialize JSON responses from HTTP queries, but I'm stuck with an issue. That's because the response can send two types of object under same property, as shown below: 1st case sample (most common): { "type": "myType", "tid": 4, "action": "myAction", "method": "myMethod", "result": { "success": true, "total": 4, "records": [ { "id": 4, "nome": "PRIMEIRO NOME", "sigla": "PN" }, { "id": 1974, "nome": "SEGUNDO NOME", "sigla": "SN" }, { "id": 2584, "nome": "TERCEIRO NOME",

Deserialize JSON which can have different objects under same property name

偶尔善良 提交于 2021-02-09 11:05:56
问题 I'm using JSON.NET to deserialize JSON responses from HTTP queries, but I'm stuck with an issue. That's because the response can send two types of object under same property, as shown below: 1st case sample (most common): { "type": "myType", "tid": 4, "action": "myAction", "method": "myMethod", "result": { "success": true, "total": 4, "records": [ { "id": 4, "nome": "PRIMEIRO NOME", "sigla": "PN" }, { "id": 1974, "nome": "SEGUNDO NOME", "sigla": "SN" }, { "id": 2584, "nome": "TERCEIRO NOME",