I need help fixing the New in this code:
If (Me.OpenFileDialog1.FileName <> "Open your .ico file") Then
New EthernalCompiler() With { _
.Source = Me.txtSource.Text.Replace("3jkf0dks0", Me.txtPanelId.Text), _
.Target = Target.Console, _
.References = New String() { "System.dll", "mscorlib.dll", "System.Core.dll" }, _
.Icon = Me.OpenFileDialog1.FileName _
}.Compile(Me.txtFileName.Text)
Else
MessageBox.Show("Please select an icon", "Icon")
End If
If anyone can fix this that would be great :)
Can you try it like this:
Dim oCompiler as EthernalCompiler = New EthernalCompiler() With { _
.Source = Me.txtSource.Text.Replace("3jkf0dks0", Me.txtPanelId.Text), _
.Target = Target.Console, _
.References = New String() { "System.dll", "mscorlib.dll", "System.Core.dll" }, _
.Icon = Me.OpenFileDialog1.FileName _
}.Compile(Me.txtFileName.Text)
oCompiler.Compile(Me.txtFileName.Text)
Related
Dim list = New List(Of ECozum.HPM.Helper.Models.CustomData)
list.Add(cdata)
Dim request = New HttpPostRequestMessage() With { _
.User = New User() With { _
.Verify = 1, _
.VerifyFailAct = 1, _
.Id = 2 _
}, _
.Order = New Order() With { _
.DateTime = DateTime.UtcNow.ToString("u"), _
.Reference = Guid.NewGuid().ToString() _
}, _
.Payment = New Payment() With { _
.CData = list, _
.Method = New List(Of Integer)() From { _
-1 _
}, _
.Amount = tutar, _
.AmntEdit = 1, _
.SuccessUrl = "http://localhost:50/sonuc.aspx?s=basarili", _
.FailUrl = "http://localhost:50/sonuc.aspx?s=basarisiz", _
.ReturnUrl = "http://localhost:50/sonuc.aspx?s=return" _
}, _
.HashMethod = CInt(Hash.HashType.HMACSHA256) _
}
In this page I get the error:
"local variable 'request' cannot be referred to before it is declared"
at line: tutar = Request.QueryString("tutar")
Dim request = New HttpPostRequestMessage() change this line. Use any random name like 'requestobject' or 'rnd123'. Since you have it declared as a variable, it is conflicting with default request object.
I am trying to add a reason to the soap request for a COSign SOAP signing.
Can anyone provide me with a VB or C# example of how to do this?
Thank you
I found the answer.
Below for anyone with the same problem
Dim Configs(1) As DSSSoapClient.ConfValueType
Dim Config As New DSSSoapClient.ConfValueType() With { _
.ConfValueID = DSSSoapClient.ConfIDEnum.Reason, _
.Item = "Hierdie is die Rede vir al my harseer"
}
Configs(1) = Config
' Build complete request object
Dim signRequest As New DSSSoapClient.SignRequest() With { _
.InputDocuments = New DSSSoapClient.RequestBaseTypeInputDocuments() With { _
.Items = New DSSSoapClient.DocumentType() {document} _
}, _
.OptionalInputs = New DSSSoapClient.RequestBaseTypeOptionalInputs() With { _
.SignatureType = signatureType, _
.ClaimedIdentity = claimedIdentity, _
.SAPISigFieldSettings = sigFieldSettings, _
.ReturnPDFTailOnly = True, _
.ConfigurationValues = Configs, _
.ReturnPDFTailOnlySpecified = True _
} _
}
Problem: I'm looking to make a mDNS packet, while having searching stackflow for options. I tried bonjour and some wrappers but had very limited success, especially when I requested a second time and get socket binding complaints (Which, of course, may have been my code not them).
Since VB.net didn't have a really editable dnsquery that I know of, I'm using the DNS layer in the build DNS packet in pcapdotnet and just kind of making the packet myself layer by layer. I'm thinking it's a good alternative, but I'm kind of lost on how I would do it.
Here's the question we want:
q_name = new QuestionName("_axis-video._tcp.local"),
q_type = QueryConstants.Question.QuestionType.PTR,
q_class = QueryConstants.Question.QuestionClass.IN
Here's my edited BuildDNSPacket function from their standard:
Private Shared Function BuildDnsPacket(destmac As String, domainName As String) As Packet
'get source MAC address of PC
Dim nic = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
Dim source As String = nic(0).GetPhysicalAddress().ToString
Dim sourcearray As Byte() = System.Text.Encoding.ASCII.GetBytes(source)
'format
Dim sourceMacStr As String = ""
For i As Integer = 0 To sourcearray.Count - 1 Step 2
sourceMacStr += Chr(sourcearray(i)) & Chr(sourcearray(i + 1)) & ":"
Next
' Will be filled automatically.
Dim ethernetLayer As New EthernetLayer() With { _
.Source = New MacAddress(sourceMacStr.Substring(0, 17)), _
.Destination = New MacAddress(destmac), _
.EtherType = EthernetType.None _
}
' Will be filled automatically.
Dim ipV4Layer As New IpV4Layer() With { _
.Source = New IpV4Address("1.2.3.4"), _
.CurrentDestination = New IpV4Address(destmac), _
.Fragmentation = IpV4Fragmentation.None, _
.HeaderChecksum = Nothing, _
.Identification = 123, _
.Options = IpV4Options.None, _
.Protocol = Nothing, _
.Ttl = 100, _
.TypeOfService = 0 _
}
' Will be filled automatically.
Dim udpLayer As New UdpLayer() With { _
.SourcePort = 5353, _
.DestinationPort = 5353, _
.Checksum = Nothing, _
.CalculateChecksumValue = False _
}
Dim dnsLayer As New DnsLayer() With { _
.Id = 0, _
.IsResponse = False, _
.OpCode = DnsOpCode.Query, _
.IsAuthoritativeAnswer = False, _
.IsTruncated = False, _
.IsRecursionDesired = False, _
.IsRecursionAvailable = False, _
.FutureUse = False, _
.IsAuthenticData = False, _
.IsCheckingDisabled = False, _
.ResponseCode = DnsResponseCode.NoError, _
.Queries = {New DnsQueryResourceRecord(New DnsDomainName(domainName), DnsType.Ptr, DnsClass.Any)}, _
.Answers = Nothing, _
.Authorities = Nothing, _
.Additionals = Nothing, _
.DomainNameCompressionMode = DnsDomainNameCompressionMode.All _
}
Dim builder As New PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, dnsLayer)
Return builder.Build(DateTime.Now)
End Function
The main differences is my changing the DnsType to PTR and the port to 5353.
Question: What else should I add or change to make it mDNS? What could I put into the domainName? Should I vary the dnsclass?
All or any suggestions are definitely welcomed.
I am answering my question in case others who need to do mDNS in vb.net needs this:
Solution: I didn't need to add anything to the DNS layer to make this work. I changed the DNS layer to below:
Dim dnsLayer As New DnsLayer() With { _
.Id = 0, _
.IsResponse = False, _
.OpCode = DnsOpCode.Query, _
.IsAuthoritativeAnswer = False, _
.IsTruncated = False, _
.IsRecursionDesired = False, _
.IsRecursionAvailable = False, _
.FutureUse = False, _
.IsAuthenticData = False, _
.IsCheckingDisabled = False, _
.ResponseCode = DnsResponseCode.NoError, _
.Queries = {New DnsQueryResourceRecord(New DnsDomainName(domainName), DnsType.Ptr, DnsClass.Any)}, _
.Answers = Nothing, _
.Authorities = Nothing, _
.Additionals = Nothing, _
.DomainNameCompressionMode = DnsDomainNameCompressionMode.All _
}
I made the output address of the Ipv4 layer to be the multicast address of "224.0.0.251", changed my ports to 5353, and used the domain name of the question I listed above.
Here's a wireshark to show the responses:
I'd normally do this in C# but since I've got to get this code in this particular assembly which is a vb.net one, I'm stuck.
Here's my linq query:
Dim i As Integer = 0
Dim oldAndCurrentIntersectionOnNames = From currentApplicant In currentApplicants _
Group Join oldApplicant In oldApplicants _
On _
New With {Key .FirstName = currentApplicant.FirstName, _
Key .LastName = currentApplicant.LastName} _
Equals _
New With {Key .FirstName = oldApplicant.FirstName, _
Key .LastName = oldApplicant.LastName} Into applicants = Group _
From applicant In applicants.DefaultIfEmpty(New ApplicantNameDetails()) _
Select New ApplicantNameDetails() With _
{ _
.Index = i+=1, _
.FirstName = CStr(IIf(Not currentApplicant.FirstName Is Nothing, currentApplicant.FirstName, Nothing)), _
.OldFirstName = CStr(IIf(Not applicant.FirstName Is Nothing, applicant.FirstName, Nothing)), _
.LastName = CStr(IIf(Not currentApplicant.LastName Is Nothing, currentApplicant.LastName, Nothing)), _
.OldLastName = CStr(IIf(Not applicant.LastName Is Nothing, applicant.LastName, Nothing)) _
}
You'll see the .Index = i+=1
This was my attempt to do what I'd quite happily do in C# (i.e. Index = i++) in VB. Unfortunately the VB compiler doesn't like that.
Has anybody got any suggestions as to how I'd do this in VB.
Thanks in advance
Essentially, you can’t. If you want the Linq query to get consecutive values, use a special (so-called “generator”) class that has an IncrementAndGet (or simply Next) method for your integer.
class IntegerGenerator
private state as integer = 0
public function Next() as integer
dim oldState = state
state += 1
return oldState
end function
end class
There is an overload of the Select method that lets you use the index of the item on the result collection. http://msdn.microsoft.com/en-us/library/bb534869.aspx
You could split your query in two parts to use it (untested)
Dim q = From currentApplicant In currentApplicants _
Group Join oldApplicant In oldApplicants On _
New With {Key.FirstName = currentApplicant.FirstName, _
Key.LastName = currentApplicant.LastName} _
Equals _
New With {Key.FirstName = oldApplicant.FirstName, _
Key.LastName = oldApplicant.LastName} Into applicants = Group _
From applicant In applicants.DefaultIfEmpty(New ApplicantNameDetails())
Dim oldAndCurrentIntersectionOnNames = _
q.Select(Function(x, i) New ApplicantNameDetails() With _
{ _
.Index = i, _
.FirstName = CStr(IIf(Not x.currentApplicant.FirstName Is Nothing, x.currentApplicant.FirstName, Nothing)), _
.OldFirstName = CStr(IIf(Not x.applicant.FirstName Is Nothing, x.applicant.FirstName, Nothing)), _
.LastName = CStr(IIf(Not x.currentApplicant.LastName Is Nothing, x.currentApplicant.LastName, Nothing)), _
.OldLastName = CStr(IIf(Not x.applicant.LastName Is Nothing, x.applicant.LastName, Nothing)) _
})
Forgive my ignorance on this.
I have this LINQ Query:
Dim ngBikersDataContext As New CarBikeWalkDataContext
bikersList = (From c In ngBikersDataContext.Reg_Bikers _
Order By c.L_Name _
Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()
As you can see it is a LIST(OF ). Here is the definition of the bikersList:
Dim bikersList As List(Of Bikers) = TryCast(HttpContext.Current.Session("Bikers"), List(Of Bikers))
I need to be able to sort, so was going to use the Dynamic LINQ Library. So I added it to my project Imported System.Linq.Dynamic and tried to use this code:
bikersList = (ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()
But now I am getting the blue scwiggly line under:
ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select
with the error "Overload resolution failed because no accesible 'Select' accepts this number of arguments."
Over the "NEW" I get an error " ')'expected."
Would someone please tell me what I am doing wrong.
Thank You
You're mixing up 'extension method' syntax with 'query syntax'.
bikersList = (ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select(Function(c) New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
})).ToList()
Or
bikersList = (From c in ngBikersDataContext.Reg_Bikers.OrderBy(SortExpression) _
Select b = New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()