Jump to content
Xtreme .Net Talk

inzo21

Avatar/Signature
  • Posts

    76
  • Joined

  • Last visited

Personal Information

  • Occupation
    Struggling Developer
  • Visual Studio .NET Version
    2003
  • .NET Preferred Language
    VB

inzo21's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi there. Thank god for beer! The current predicament of the week is as follows: I have two assemblies in a single solution, A and B. Assembly A is an application that installs a context menu into the file system (like that Winzip Icon when you right click on a file). When a user clicks on one of the options to that function, such as "Add this file!", a new object of assembly is instantiated and the method AddFile(filename) is called - then the object is disposed. The AddFile method simply appends the name of the working file to a text file in the same directory as the calling assembly. If the file does not exist, it creates it. Here is the code I used to get the executing assembly: Private myassembly As System.Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly() Private tempfile As FileInfo = New FileInfo(myassembly.Location) Private m_filelist As String = tempfile.DirectoryName & "\FileList.txt" This works great when I compile and run it in V Studio . NEt. The context menu works and the text file gets created when not present. However...when I create an installation package and deploy the app, I'm not getting the anticipated result. Everything installs and all .dll's are copied to the program directory. The menu works fine - the only issue I have is that it is writing back to the directory where I compiled the original code for the context menu (assembly A) - as opposed to the application directory. Does anyone have an idea of why this would happen? When I isolate the Assembly B and call AddFile from a command line app, it works fine when deployed. The issue seems to be in the method I am calling or instantiating an object of class B from Assembly A. this kept me up many nights so any help would be much appreciated. Thanks in advance, inzo
  2. Still not working. Okay - I took a look at the article you suggested PDamp and got some things out of it. I came up with the following test mod - which still isn't functioning. Module Module1 Sub Main() Dim cryptoprovider As RijndaelManaged = New RijndaelManaged Dim key As Byte() = {11, 2, 7, 24, 16, 22, 4, 38, 27, 3, 11, 10, 17, 15, 6, 23} Dim iv As Byte() = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} Dim xtw As XmlTextWriter Dim filename As String = "c:\testing\test.xml" Dim FileWriter As FileStream = New FileStream(filename, FileMode.Create) Dim CryptoWriter As CryptoStream = New CryptoStream(FileWriter, cryptoprovider.CreateEncryptor(key, iv), CryptoStreamMode.Write) xtw = New XmlTextWriter(CryptoWriter, System.Text.Encoding.UTF8) 'FileWriter.Close() Console.WriteLine("File Encrypted") Console.ReadLine() xtw.Close() Dim FileReader As FileStream = New FileStream(filename, FileMode.Open) Dim CryptoReader As CryptoStream = New CryptoStream(FileReader, cryptoprovider.CreateDecryptor(key, iv), CryptoStreamMode.Read) 'FileReader.Close() Dim XmlDoc As XmlDocument = New XmlDocument Dim XmlReader As XmlTextReader = New XmlTextReader(CryptoReader) Try XmlDoc.Load(XmlReader) Console.WriteLine("file..............") Console.WriteLine(XmlDoc.OuterXml.ToString) Console.ReadLine() Catch ex As XmlException Console.WriteLine(ex.ToString) Console.ReadLine() End Try End Sub End Module I get a system.xml.xmlexception - the root element is missing error. The file is being encrypted but it seems that either the decryption is not working or there is garbage going in there that I can't parse out. Any ideas? inzo
  3. Hello all, the predicament for the evening. I have a well formed xml file used for configuration in an application. I want to decrypt/encrypt this file when it gets used - thus when the app loads it decrypts and loads the contents in an xmldocument - when the app exists it encrypts and saves the contents back to the file. I figured this would involve the following pseudo-code. on app load 1. read file into a byte array 2. run byte array through class.decryptfunction - returns another byte array 3. read returned byte array into memory stream 4. serialize memorystream into well-formed xml doc 5. load memorystream into xmldocument object for processing without any encryption, I tried declaring an array of bytes and loading the contents of the xmldoc into this array. I then created a memorystream and read the contents of the byte array into that stream. I finally tried load the memorystram into the xmldocument. Try Dim mymem As MemoryStream = New MemoryStream Dim ar() As Byte = PrepFile(FileLocation) mymem.Write(ar, 0, ar.Length) Console.WriteLine("byte ar: " & mymem.Length) configfile.Load(mymem) Console.WriteLine(configfile.OuterXml) Catch e As Exception Console.WriteLine("Exception: {0}", e.ToString()) End Try the array and mem stream have data - but I receive an XMLException - root element missing. I'm guessing that this has something to do with serialization. Does anyone have any ideas how to accomplish this or can they point me to a good article or two. thanks, inzo
  4. Really weird Okay - on a whim, I tried adding a parameter to to the method so that in the web service it reads: public function getstring(s as string) as string s = s & "-test" return s end function I then call the proxy to this as dim proxy as myservice.myclass = new myservice.myclass proxy.getstring("client call") and it works. The only change was adding a parameter to the method call. Now I'm completely confused. Does anyone have any idea what is going on in the backend? inzo
  5. No soup! Hey VB... I tried your suggestions and I guess it seems to be a problem with the serialization. I placed option strict on, and attempted passing a string from the web service. In the client, I create a string object and make it equal the proxy.getstring() function from the web service. It compiles, but at runtime I get the following error: An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll Additional information: Cast from type 'XmlNode()' to type 'String' is not valid. I am able to call other functions and subroutines from the web service - but they are returned as byte arrays. At this point, I'm still not sure what I'm doing wrong. Do you think I need to serialize the string into xmla nd then deserialize it on the client end? thanks again for the help. I really need it as I learn this stuff. inzo
  6. Hello all, new problem of the day. I want to pass a list of string names in from a web service to a client. I have tried using both an array of strings, an arraylist, and a collection - all to no success. My preference is to use an arraylist for the iteration and array manipulation methods already built in. Here is the error I get: Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.Collections.ArrayList may not be used in this context. On the service, I use the following code for testing. Public Function GetManifest() Dim tar As New ArrayList m_mancounter = 0 tar.Add("test") tar.Add("test2") Return tar End Function the client code reads: Public Sub GetAllFiles() 'Try Console.WriteLine("processing manifest") Dim availablefiles As Object Dim proxy As myservice.servmethods = New myservice.servmethods availablefiles = proxy.GetManifest Console.WriteLine("filecount: " & availablefiles.Count.ToString) If Not (availablefiles.Count = 0) Then For Each i As String In availablefiles Console.WriteLine("file: " & i) Next Else : Console.WriteLine("Array is Empty!") End If 'Catch ex As Exception 'End Try End Sub I declare an object rather than an arraylist based on an article I read here from VBAhole... I think ;-) Does anyone have any clue what I'm doing wrong or have any ideas on how I can send this info over without high bandwidth - i.e. no xml docs or class bojects? thanx in advance inzo
  7. got it! Okay - for all those reading. The httpruntime element that you can configure / set in the web.config file for web services, applies only towards uploads according to msdn. Thus I test this by doing a file transfer app that transfers to a web service that only accepts 1 mb files. In reverse, I was able to pull files larger than 1 mb (tested 30mb) off of the server byte copying a simple byte array from the web service to the client machine. just an fyi for everyone. inzo
  8. Hello all, I'm in the process of developing an app that transfers files to and from a file server via web services. I know that to use web services, you can either break the file up in chunks that are less then 4 MB or set the maxlength property. This is primary to protect against DOS attacks and help with the SOAP processing. Now, the question. Is this technique applicable only for incoming requests - i.e. posting to the file server web service. What I want to know is if I need to reverse the process when a uses wants to download a file from the file server? As the request would be getting a file, is there a way to allow downloads to be downloaded with having to break them up on the file server and reassemble them on the client? thanx in advance. inzo
  9. Hello all. I wrote an application that takes a file, encrypts it, compresses it, and splits it up for processing on a web server. The original design called for the splitting a file off of a memorystream - but I watch the memory usage spike up to about 100MB in the Task Manager. If I split the file off of an actual file, I get a much lower memory usage - about 60MB - but the processor utilization is higher by about 20 percent. It's an asynchronous app. This will be used for transferring files to and from a web server in a local network. My question: Which do you think is better - using more memory with a lower CPU rate or a higher CPU utilization but lower memory requirements. thanks for your thoughts. inzo
  10. Hello All, Okay - here is the dilemma. I am trying to transfer large data files via web services in a file transfer apaplication that is implemented over the internet. I have a client app that calls the file transfer method of eh web service and passes it a filename, directory to put the file in and an array of bytes represnting the file. I know that the default files size is about 4 MB and I changed the allowable size in web.config. But I don't want to open myself up to DOS attacks and such. Thus, I want to beable to break the file up and send chunks of data to the web service and then have it reassembled on the file server end where the web service sits. Once reassmebled, it save into the driectory specified. The key part, is that I want to do this asychronously so as to not maintain a session - although if I can't, I can't. I don't even know where to begin. I have the array of bytes - but I'm not sure how to both break that array down into a set size and then pass those chunks to a receiving method that reassmbles it. Does anyone have any code or pseduo-code they can offer to help me get started. I ahve reviewed the info on MSDN with their cold storage strategy - it wasn't that clear though. thanks in advance. inzo
  11. Got It! I love Microsoft!!! ;-) The issue seemed to be instantiating a directory object. When I isolated this with another web service, it had a hard time with the constructo - stating it was deemed private. I did some searching and found that I needed to call the operation outright. Thus, I replaced the directory check with the follwing code: If Not (Directory.Exists(fulldirpath)) Then Directory.CreateDirectory(fulldirpath) End If Dim fullpath As String = fulldirpath & "\" & filename works fine now. Thanks for the interest though Pdamp. You seem to always be around. inzo
  12. getting there Hey pDamp - I tried that. Thanks though. I've narrowed it down to the inability for it to create the directory. When I pulled out the following piece of code and hardcoded a directory to write the byte array to, it worked fine. Dim ds As Directory If ds.Exists(dirname) Then Debug.WriteLine("Dir Exists") Else ds.CreateDirectory(dirname) Debug.WriteLine("Directory Created!") End If still stuck on this. inzo
  13. Hello All, I'm trying to call a webmethod that accepts three parameters - a filename, a dirname, and an array of byte. The goal is to create the directory passed and transfer the file from client to server. Pretty straightforward. I'm testing on a WinXP Pro box with IIS 6. When I run my test module however, I get an error dealing with insuffucient access to write to the directory. However, the directory does get created - it just hangs when it tries to create the file and write the bytes to it. I have tried setting the code access permissions for the .Net framework (i.e. Admin tools - .Net Configuration - Machine - Local Intranet Zene and set the Permission set to full access and the membership condition to all code. Still the same error. Specifically, I get this error: An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Access to the path "testing" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path) at System.IO.Directory.CreateDirectory(String path) at BTFileTransferApps.Service1.SaveThisFile(String filename, String dirname, Byte[] bytearray) in C:\Inetpub\wwwroot\BTFileTransferApps\FileWorks.asmx.vb:line 69 --- End of inner exception stack trace --- my web service call looks like this: <WebMethod()> _ Public Sub SaveThisFile(ByVal filename As String, ByVal dirname As String, ByVal bytearray As Byte()) Debug.WriteLine("process started from web...file: " & filename) Dim ds As Directory If ds.Exists(dirname) Then Debug.WriteLine("Dir Exists") Else ds.CreateDirectory(dirname) Debug.WriteLine("Directory Created!") End If Dim fullpath As String = "c:\servertest" & "\" & dirname & "\" & filename Debug.WriteLine("web - dir name: " & dirname) Debug.WriteLine("web - file name: " & filename) Debug.WriteLine("web - full name: " & fullpath) Debug.WriteLine("Attempting to save file!") Dim fsInput As FileStream = New FileStream(fullpath, FileMode.Create, FileAccess.Write) fsInput.SetLength(0) fsInput.Write(bytearray, 0, bytearray.Length) fsInput.Close() Debug.WriteLine("File created from Byte Array") End Sub anyone have any ideas. thanx, inzo
  14. if it's an identity, you can add an output parameter to the stored procedure declare ( @value ) increment you field here set @value = @@identity. the @@identity will return the last value generated automatically for the inserted record. If you are returning another feidl value other than an identity, the same method should work. inzo
  15. maybe...? I like your handle. Perhaps you can mount the network resource as a drive to the fileserver that you are trasnferring to and reference it via straight unc or file url? On the loop question, I noticed that in your loop, you are instantiating a new instance of yuour web service method for each item in your array. You might want to reconstruct the method and call a particular function of a single instance for every service in the ar5ray. I have a file transfer service that recursively scans directories and transfers files using this method. It's less garbage to clean up and a little more efficient. just an idea. inzo
×
×
  • Create New...