public static void Test() { byte[] arrayCertificate;
[Code]....
But this certificate doesn't have a "Subject Unique Identifier" Take a look at this:
[URL] (The part of Structure of a certificate)
And I want to know how can I read that value from my .NET code (I looked that I can get SerialNumber, Thumbprints and others but there is no Subject UID anywhere).
If anyone can share an openssl command to include this UID for the certificate :-) (pfx one)
I am trying to do some x509 encryption and I am getting lost. I have generated my own self signed cert with OpenSSL, but am confused as to how to use my public key to encrypt.I found a few examples online, but in the first one, I do not see where you provide your cert or key for the encryption. url....The seccond is in C#, and although i can make sense of most of it, the line in particular tha tlooks important, but I can't translate to VB is this one: url....
I have a signedXML object Dim signedXml As New SignedXml (envelope)I need to set the SigningKey property of this object signedXml.SigningKey..I also have my certificate object Dim cert As X509Certificate = Me.GetX509Certificate...How can I set the SigningKey property of signedXml using my cert.In .NET 2.0 each X509Certificate had a 'Key' property which returned an RSA object, but in 3.5 this property is removed.
Greetings, I am trying to install a certificate from a .p12 file into the Local Machine - Personal store and set the permissions for Everyone to full control. I can acheive this manually with mmc on W7 (or mmc + WSE Certificate Tool on XP.) When attempting with the vb.net code below I get no errors but when I try to access the security tab (Manage Private Keys in mmc on W7, or WSE Certificate Tools on XP) I get the error, "No keys found for certificate!"
I am using the following code to install the certificate, which seems to be working. However I am not convinced its placing the private key in the correct place. I have tried two methods for setting permissions on the private key and the second method, which locates the private key file indicates the private key is being stored under usersmy-user-account... Should that be a public account
I have the following problem with MEF: Interface definition to be used by host:
Public Interface IExecuteDoSomething Inherits IAddinSettings Event DataReceived As EventHandler(Of DataReceivedEventArgs) Function DoSomething() As Boolean End Interface
[Code]...
Everything seems to work fine until the Button2_Click routine is executed, then an InvalidCastException is thrown with the info:Unable to cast object of type 'System.Collections.Generic.List1[SharedLibrary.IExecuteDoSomething]' to type 'System.Collections.Generic.List1[SharedLibrary.IAddinSettings]'.
How can i solve this problem, because the imported object implements both of the interfaces?
I have a object type variable (control .Tag) that I need to cast to a structured type, and change a member in. This is a contrived but representative example
get around this. I have a data base field that is a decimal data type and I want to display it in a text box with the following txtWeekdayRate = CType(RoomsDataRow!WeekdayRate, TextBox)I get the following error when I run my program.Unable to cast object of type 'System.Decimal' to type 'System.Windows.Forms.TextBox'.
I am getting the followin error from my code. System.InvalidCastException was unhandled Message="Unable to cast object of type 'QADBASE.DMRDataLists' to type 'QADBASE.DMRData'." Source="QADBASE" I am getting the error in the code below on the createDMRIssue
I have an Entity class which Implements IWeightable:
Public Interface IWeightable Property WeightState As WeightState End Interface
I have a WeightCalculator class:
Public Class WeightsCalculator Public Sub New(...) .. End Sub
Why can I not do wc.Calculate(entities)? I receive:
Unable to cast object of type 'System.Collections.Generic.List1[mynameSpace.Entity]' to type 'System.Collections.Generic.IList1[myNamespace.IWeightable]'.
If Entity implements IWeightable why is this not possible?
I have tried everything to no avail. I need to cast the value from a user selected dropdownlist to another dropdownlist on another page. The data in the textboxes are a series of numbers. Also is there a way to display the value in the second dropdown list as well as other values? For example, my dropdown has the values 1-6, user selects 4, which displays first in the dropdown on page 2 but the other values also display in case they want to change there selection??
If Not Page.PreviousPage Is Nothing Then Dim table As Control = PreviousPage.Controls(0).FindControl("table1") Dim ddl As DropDownList = CType(table.FindControl("ddlB_Codes"),c DropDownList)
I'm trying to obfuscate some VB.NET 2003 app.The resulting assemblyes are obfuscated and "run" with some errors.I cleaned all potential reflection problems, but I'm not being able to read the selected value of a combobox.
I load the Combobox using their Datasource properties, using a collection of "VTPair" (a class created by me with 2 properties: one of string type and other of object type to store the value)
This combobox handle pairs like "Male | M" or "Female | F".When trying to see what is selected, I use if mycombo1.SelectedValue = "M" then.This code, after obfuscation, throws me an exception that cannot cast type "XX" to string "M".
So, I changed the code to something more correct, explicitly casting the selected value to String:
if ctype(mycombo1.SelectedValue,string) = "M" then But the error is the same.Debugin my original code, the SelectedValue property is of type "Object" but it is a string.I tried using the ComboBox.SelectedItem property that is also an object but this time what is inside is of type "VTPair" (my own class) and then trying to access its "Value" property (which is of type Object) and trying to cast to string fails again.
Does anyone have an idea to "translate" this piece of code to work OK after Dotfucate it?
I have an object that inherits from an interface. I can create and return the following:
Dim o As IRequest o = New Request Return o
This works fine. Now I want to return a List(Of Requests), so I try the following:
Dim o As List(Of IRequest) o = New List(Of Request) Return o
The error below is being given on o = New List(Of Request)
System.Collections.Generic.List(Of MyObjects.Request)' cannot be converted to System.Collections.Generic.List(Of MyInterfaces.IRequest)'.Consider using 'System.Collections.Generic.IEnumerable(Of MyInterfaces.IRequest)'
Say I have a interface called IProperties and I have a collection called colMyProperties that is a collection of IProperties. Then I have an object called clsProperty that implements the IProperty interface. Now, in my code where I add objects to the colMyProperties collection I add a bunch of clsProperty objects. so far so good.
Now when I try to access an object in the collection I can only access properties and methods of the IProperties interface, not the clsProperty object. What am I doing wrong? Do I need to cast the object?
I usually avoid VB's built-in conversion functions (CStr, CDate, CBool, CInt, etc.) unless I need to do an actual conversion. If I'm just casting, say from an object to a string, I normally use either DirectCast or TryCast, under the assumption that CStr, etc., are doing some extra stuff I don't need. But sometimes the DirectCast syntax is a little cumbersome, as in the following example.[code]SqlDataReader.Item returns an Object, which needs to be cast to a String. CStr is easier to read, type, and explain (IMO). My question is, does it matter which one I use? Should I just go with CStr (and CDate and CBool, etc.) and not worry about the extra work I assume those functions are doing? Is there any other downside to using these functions?
i have the following code which walks through an Excel file and this works fine note that the following line does work well (folder is being set earlier in the code)
When I have many controls on a Form (i.e. Label, Button etc) that do almost the same thing, I often use one method to handle all the controls Click, MouseDown, MouseUp events.But to know which of the controls throwing the event and access the properties of that control I need to cast the "sender" object to the correct type.
The thing is that I always know which type it is, I don't really have to "TryCast", "DirectCast" and check if the operation returns true. I some times use CType as well.
Delegate Sub UpdateTextHandler(ByVal recbuffpass() As Integer)
Private Sub someSub() Dim f As frmMain = My.Application.OpenForms("frmMain") f.Invoke(New UpdateTextHandler(AddressOf f.UpdateTextMethod), New Object() {recbuf})
I've got a project called Service.Inside the project, i've got 2 windows classes.ClassA is the main windows class which opens up when I run the program.On ClassA, I've got a button which, when I click it, opens up ClassB which is the other windows class. Inside the button's eventhandler (click), I've got a string which contains the name of ClassB's class ie "ClassB". I will probably get this from a table. Is it possible to initiate the object ClassB without using if statments to check what the type of object is. In the code below, i've managed to create a o of type object, but i need to new it with the ClassB
vb.net Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
I have the following VB.NET code that I am using to sort a Data.DataTable by column count.
For Each dtTarget As Data.DataTable In _ From x In Target.Tables _ Where DirectCast(x, Data.DataTable).Rows.Count > 0 _ Order By DirectCast(x, Data.DataTable).Columns.Count ... Next
Is there a way to indicate that x is a Data.DataTable without having to DirectCast it each time it is referenced (twice in this case) in the LINQ query?
I wonder if this is not possible dim mystring as string="1" dim myint As Nullable(Of Integer) myint=0 myint=mystring It crashes on the last line why is that? mystring is already integer (1) , i dont have to cast using cint, i thought. option strict off- if this cause the problem