|
OK, after looking at that bigger example, that's not JSON.
I don't know of a library that handles serialization of PHP objects.
But, there is this[^]. You can create a PHP project in your solution that handles serialization and deserialization, creating the objects for you.
You can NOT just use an external PHP app because the objects that it creates will not be visible to your .NET code.
|
|
|
|
|
The web doc for Phalanger seems a bit complex.
What I need is
SomeVar = ToClass.ToFunction(BlobString)
Plalanger goes into web pages, complex class functions and cannot see how. Perhaps the simple calculates factorial example technique with
php
Function ToFunction($str)
{
$ar = unserialize($str);
return serialize($array);
}
VB
Dim Ojb as object = ToClass.ToFunction(MyBlobString)
would work???
|
|
|
|
|
You can't do that. At. All.
You cannot combine two different languages in the same code file. You can't even use two different languages in the same Project!
The PHP and Managed code execute in completely separate execution environments that don't even know about each other. So, the objects you create in one are not visible in the other.
Your only nice solution is to create a seperate PHP project (essentially PHP.NET) that handles serialization and reference it in the VB.NET code.
|
|
|
|
|
If separate programs are created then I am back to a php program creating a file that VB.Net needs to read and Deserialize into some table. So what good is that except possible to make the external interface file being more 'friendly' i.e. Key,Value instead of all the types, length, etc. And this may not work for embedded structions which I believe this blob has.
Since each record that I read would need to do the same thing it doesn't even seem to be very practical.
|
|
|
|
|
QuickBooksDev wrote: If separate programs are created
A seperate project in the same solution is compiled to a library .DLL, not a seperate .EXE.
It's not different than if you added a C# Class Library project to your Solution.
|
|
|
|
|
This might help:
Sharp Serialization Library serializes and deserializes primitives, ArrayLists and Hashtables, compatible with PHP serialize().
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sharp Serialization Library did not work.
Failed in their test project on
Hashtable htFile = (Hashtable)this.serializer.Deserialize(stSerial);
Unable to cast object of type 'System.String' to type 'System.Collections.Hashtable'.
I just clicked on open. Browsed to my file with the data and that was it.
|
|
|
|
|
In a vb.net 2010 application, I am going to add a interface for a user to be able to do the following:
1. See what users are assigned to 5 specific active directory groups, and
2. allow the user to update the active directory groups.
Thus can you show me and/or point me to a url that shows me example code on how to accomplish this goal?
In an existing vb.net 2010 web form application, I am going to add an web interface for a user to be able to do the following:
1. See what users are assigned to 5 specific active directory groups, and
2. allow the user to update the active directory groups.
Thus can you show me and/or point me to a url that shows me example code on how to allow users to set the active directory groups and to update the active directory groups?
|
|
|
|
|
|
I have a problem in creating a VBA to perform a certain task. I have a data in excel which has exactly 20 rows and 1500 columns, in which 1st row of each column is the filename of a text file which has to be created in notepad. How can I copy from A2 to A20 from the first row in excel and open and paste it in a notepad and name it as (A1 value) and close it. And then again copy the 2nd row from B2 to B20 and open and paste it in a notepad and name it as the (B1 value), so on and so forth for 1500 columns. How can I program this task other than manually copying from excel and pasting it in a particular notepad. Kindly guide me
|
|
|
|
|
So... what have you tried?
This is a relatively simple task in VBA.
If you provide the code you've written, others may assist.
But do not expect anyone to simply provide the code.
|
|
|
|
|
I have tried this formula of visual basic which is as stated below
Sub writetotextfile1()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A1.txt" For Output As #1
For Each rngLoopRange In Range("A2:A20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
But this copies only the data range from A2:A20 and opens a notepad and pastes there and renames it as A1 and closes it and then comes back to the same worksheet of excel. I am not able to do rename it as A1(value) and I was not able to create a single macro which can run for the subsequent B2:B20, C2:C20, so on and so forth. Can you improvise this formula for me, please?
|
|
|
|
|
Hi Tim Carmichael,
I got the solution myself. Thanks for making me also believe that I can do it. I am very happy that my macro is working as per my requirement and saving me a lot of time.
Warm Regards,
R. Sudhakar
|
|
|
|
|
I am glad you worked it out for yourself.
|
|
|
|
|
Hi Tim Carmichael,
I have created a visual basic program as follows:
Sub writetotextfile1()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A1.txt" For Output As #1
For Each rngLoopRange In Range("A1:A20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
Sub writetotextfile2()
Dim rngLoopRange As Range
Open "C:\Users\Kanini\Desktop\VisualSudhu\A2.txt" For Output As #1
For Each rngLoopRange In Range("B1:B20")
Print #1, rngLoopRange
Next rngLoopRange
Close #1
End Sub
These are the macro created for 2 files created text format. But, I need to create it for 500 rows at a time, so that it can give me 500 text files. Is there any way that I can loop these macros and as well create a formula where in I can get 500 rows at a time. Kindly help me in this regard.
Thanks in advance,
Warm Regards,
R. Sudhakar
|
|
|
|
|
You need a loop within a loop, one for the rows and one fro the columns - something like this:
Sub writetotextfile1()
Dim iMasterLoop As Integer, iCellLoop As Integer
iMasterLoop = 1
Dim wsLoop As Worksheet
Set wsLoop = Worksheets("Sheet1")
Do While wsLoop.Cells(iMasterLoop, 1) <> ""
Open wsLoop.Cells(iMasterLoop, 1) For Output As #1
For iCellLoop = 2 To 20
Print #1, wsLoop.Cells(iMasterLoop, iCellLoop)
Next iCellLoop
Close #1
iMasterLoop = iMasterLoop + 1
Loop
End Sub
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I'm trying to write a method that can take the path to any valid assembly and then analyze its attributes, such as title, company, and trademark, but especially custom attributes. Although I will want to get standard assembly attributes, my main purpose for this application is to get information from a custom attribute I created in another project that I add to most of my assemblies.
I have already have a method that take an assembly as a parameter and can pull the information I need. I also have a method that displays an open file dialog window where a user can select a file and then the method determines if it is a valid assembly. What I can't figure out is how to take the path to the assembly file, create an assembly object from it, and then pass it to the method that get the attributes.
He is a VERY stripped down version of the AssemblyAttributes class just to demonstrator the constructor that take an Assembly object. This class is not a concern; I have already tested all the code within this class by using the GetExecutingAssembly method and all the code worked fine:
Public Class AssemblyAttributes
Private _assembly as Assembly
Public Readonly Property Copyright as string
Get
Return GetCopyrightString
End Get
End Property
Public Sub New(assembly As Assembly)
_assembly = assembly
End Sub
End Class
And then I have my method, that gets called from a button's click event, which takes the path to an assembly (the stream writer is used later in code that is not shown to output the attribute information). This is the method where I have having trouble:
Private Sub GetAssemblyAttributes(assemblyName As String, ByRef sw As StreamWriter)
Dim currentAssembly As Assembly
Dim assemblyAttributes As New AssemblyAttributes(currentAssembly)
Dim copyright As String = assemblyAttributes.Copyright
End Sub
How can I using assemblyName to create the currentAssembly object? I have tried:
Dim currentAssembly As Assembly = Assembly.Load(name)
And got a FileLoadException and got the error message:
Could not load file or assembly 'C:\\[PathToAssembly]\\[AssemblyTryingToAnalyze].dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Next I tried:
Dim currentAssembly As Assembly = Assembly.LoadFile(name)
And got a NotSupportedException and got the error message:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous...
But this file is not from a network location; this code and the assembly I'm trying to analyze reside on the same computer.
Finally I tried:
Dim currentAssembly As Assembly = Assembly.LoadFrom(name)
And got the same exception and message as when I tried Assembly.Load .
I do understand the need to be caution loading 3rd-party libraries but I find it hard to imagine that there is no way to load an assembly simple to grab its attributes (such as the copyright notice, or custom attributes). I tried searching Google but every example I found only showed how to get attributes from the currently running assembly from within its own code. For example this works with the above code:
Dim currentAssembly As Assembly = Assembly.GetExecutingAssembly
So really in the end all I'm asking is, is there someway (and if so how) to get attributes from any assembly that a user make select? Thanks in advance for any help...this has been driving me crazy for the past few hours and my current project is kind of dead right now unless I can get this to work.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Have you tried Assembly.ReflectionOnlyLoadFrom [^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Wow...how did I miss that one?! I guess that is what I get for working on it till 3AM. I will take a look at that tonight when I get home. Thanks!
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
I am having trouble synchronizing the physical camera orientation with the shell orientation (must be a windows bug). Keep getting a picture stuck in landscape with I turn the MS Surface to portrait.
I have attempted to use the EXIF picture code and an appropriate method to determine shell orientation but the result is not consistent.
If anyone has found a good piece of vb.net code to do this function I would be grateful if you forward it to me.
|
|
|
|
|
Hi, I'm working on a small project , I'm trying to copy a selected list view item to a textbox this will then use the text in the textbox to create a text file with the name as the textbox text. here is the code I have so far:
If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 1 Then
For Each selectedItem In selectedItems
REM
REM
txtITEM.Text = lsvRQLiveFeed.SelectedItems(0).Text
My.Computer.FileSystem.WriteAllText("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\" + txtITEM.Text, +"." + ".txt", False)
Next
however I seem to get an error with the following line:
txtITEM.Text = lsvRQLiveFeed.SelectedItems(0).Text
InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index
is there any solution I have been working for a while on this issue and I'm struggling to find a solution ?
Any help with this greatly appreciated.
Regards
Pete
|
|
|
|
|
txtITEM.Text = selectedItem.Text
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thank you that has fixed the issue only now i need to tackle the next error:
Conversion from string "." to type 'Double' is not valid.
on this line:
My.Computer.FileSystem.WriteAllText("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\" + txtITEM.Text, +"." + ".txt", False)
any ideas ?
Regards
Pete
|
|
|
|
|
Yes, it's failing on the second parameter:
, +"." + ".txt", It probably reads as 0 + "." . The second parameter is the stuff that is written to the file. If you omit the first + on that line, you'd be writing "..txt" to the file.
You might want to divide the statement over multiple lines, makes it a bit easier;
Dim sPath as String = String.Format("C:\Users\Pete\Desktop\DJ Sync\DJ Sync\test\REQUEST\{0}.txt", txtITEM.Text)
Dim sContent as String = "Whatever your content is"
My.Computer.FileSystem.WriteAllText(sPath, sContent, False) Bonus points can be earned by using the SpecialFolder enum to fetch the path to the desktop-directory, and Path.Combine to build the path.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
txtITEM.Text, +"." + ".txt", False
What's wrong there ?
You can't have a "+" next to a ","
|
|
|
|