Unhandled Exception using DotNetZip - vb.net

I've been using DotNetZip for a month or so now and i like how it has worked but today my program started having a new issue that I'm clueless on.
During the zipping process it throws this error up and windows displays their "program name has stopped working" box.
Unhandled Exception: System.IO.FileNotFoundException: s:\(file path)\filename.pdf
at Ionic.Zip.SharedUtilities.GetFileLength(string fileName)
at ionic.Zip.ZipEntry.MaybeUnsetCompressionMethodForWriting(int32 cycle)
at Ionic.zip.Zipentry.WriteHeader(Stream s, Int32 cycle)
at Ionic.zip.ZipEntry.Write(Stream s)
at Ionic.zip.zipfile.save()
at ZipAJob_Instant.ConsoleMain.Main() in C:\users\(my name)\Documents\visual studio 2012\projects\zipAjob_Instant\zipAJob_Win32.vb:line 71
Line 71 refers to where i call zip.save()

From your comments, I take that what happened is exactly what happened to me a while ago.
I was getting a list of files to zip and stored into memory. The I would go zipping them one by one until this exception was thrown. The cause was someone removed the file after I got the list, but before I got the opportunity to zip it. This occured on a shared folder, btw.

Related

Why do I get, "ElementAtOrDefault' is not a member of 'System.Data.EnumerableRowCollection"?

I am trying to get a VB solution to run (just took it over to maintain). When I try to run it via F5, I get several errors, the first of which is:
Error 13 'ElementAtOrDefault' is not a member of 'System.Data.EnumerableRowCollection(Of System.Data.DataRow)'. C:\MemberOrderEntry\MembersOrderEntry\MembersOrderEntry\App_Code\commonClass.vb 908 16 MembersOrderEntry
But 2-clicking it in the Error List pane takes me to this line (line 908):
Return dset.Tables(0)(0)("Result")
The string "ElementAtOrDefault" appears nowhere in the code. How does the line above wreak this havoc?
BTW, some of ther other err msgs seem very odd, such as "'String' is not declared. It may be inaccessible due to its protection level" and "Type 'Exception' is not defined"
It seems something fundamental is flawed in this code or its configuration. The Project's Bin folder contains DAL05.dll (and DAL05.pdb), as well as four Telerik DLLs.

MQQueueManager Constructor throwing FileNotFoundException

I have the following vb.net code:
Imports IBM.WMQ
[...]
MQEnvironment.Hostname = hostName
MQEnvironment.Port = portNumber
MQEnvironment.Channel = channelName
queueManager = New MQQueueManager(queueManagerName) ' error here
which is throwing the following error:
System.IO.FileNotFoundException occurred
FileName=C:\Users\User\Documents\Visual Studio 2012\Projects\[...]\bin\Debug\mqclient.ini
HResult=-2147024894
Message=Could not find file 'C:\Users\User\Documents\Visual Studio 2012\Projects\[...]\bin\Debug\mqclient.ini'.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
I am not using any ini files in the construction of my queue manager, so does anyone have any idea what's going on - why is it even looking for one, and why in the same directory as the program? I have installed the MQ client, and afaik I have all the environmental variables, etc. set up properly.
Thanks for any help you can give
Is that an unhandled or a first chance exception? Internally, the MQ .net layer will try to read a MQClient.ini but should function quite happily without it. It reads the file for compatibility with the C client, and can handle some of the MQClient.ini stanzas. I would not have expected an absence of such a file to cause problems, but it will try to open it internally. Was that the full callstack, as I'd have expected some MQ libraries on the stack otherwise.

DBNull error - 'System.InvalidCastException'

Using Visual Studio 2008 and generating .net 2.0 framework with VB.net for a web application.
I encountered a very strange problem currently. After I build a solution and click a link in a web page, I got an error message as following. The same thing happened when I tried to run in debug mode.
*************************************** ERROR Message ******************************************************
"An exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll but was not handled in user code"
"Additional information: Operator '=' is not defined for type 'DBNull' and string "". "
*******************************************************************************************************************
The problem part is simply as below in a vb file. The value of dataview(0)(“name”) is NULL and my_name is a variable string. The strange is thing I didn't change any code in this vb file. This vb file was built previously and used for a long time ago without any problem. It just suddenly happened today. I have this syntax all over the program without causing any problem. I have tried to restore the whole solution back to original but still have the problem.
Can anyone please advise why all the sudden and how to fix?
If dataview(0)(“name”) = my_name then …
Try to determine NULL value first ..
If NOT IsDBNull(dataview(0)(“name”)) Then
If dataview(0)(“name”) = my_name then
'codes here
End If
End If

Active Directory related AppDomainUnloadedException in MVC4

I have an ASP.NET MVC application. It's run on a domain and we determine the user by calling UserPrincipal.Current. This works beautifully, most of the time. Every once in a while (maybe 1 out of 5 times), and only right after I publish my app to IIS, it will throw an AppDomainUnloadedException.
The specific line of my code causing the exception is:
if (UserPrincipal.Current.SamAccountName != null &&
_currentUserId != UserPrincipal.Current.SamAccountName) ...
The remainder of the call stack is:
mscorlib.dll!System.StubHelpers.StubHelpers.GetCOMHRExceptionObject(int hr, System.IntPtr pCPCMD, object pThis) + 0xe bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo() + 0x358 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.DnsDomainName.get() + 0x5e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.GetAsPrincipal(object storeObject, object discriminant = {Name = "UserPrincipal" FullName = "System.DirectoryServices.AccountManagement.UserPrincipal"}) + 0x17a bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate, bool useSidHistory) + 0x576 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate) + 0x35 bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType? identityType, string identityValue, System.DateTime refDate) + 0x9e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x5b bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x1e bytes
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.Current.get() + 0xc1 bytes
After a great deal of digging around, and due to the random nature of the exception, I concluded the problem was probably related to this:
http://support.microsoft.com/kb/2683913
So I installed the hotfix and as expected, the problem went away. That was Tuesday. This morning, the exception started up again. I verified that the hotifx is in fact installed. I turned on module load messages and got:
'w3wp.exe': Loaded 'C:\Windows\SysWOW64\activeds.dll', Cannot find or open the PDB file.
So I verified that that .dll is in fact the one from the hotfix and it is (size and version #s match).
At the same time I get this exception, I get this event in the event log:
A process serving application pool 'WebSitePool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '7404'. The data field contains the error number.
The only data in the error is: 0x8007006D which I believe simply means there was a fatal communication error which the error already said...
Humorously, when the exception dialog pops up it states, "If there is a handler for this exception, the program may be safely continued." Which is true if your app has no need for UserPrincipal.Current, but calling it again after this exception causes the exception to rethrow, so I'd question their "safely continued" assertion there.
Now, if I rerun the app, I won't get a problem. I have yet to have this happen any time, other than right after publishing. Because of our setup and relations to other projects, this app must be debugged under IIS, which means I have to publish it every time I make a code change which means I normally see this throughout the day (Tuesday afternoon and yesterday being the exceptions).
It seems curious to me that, from digging around, it appears this bug is frequently associated with ASP.NET MVC, but I don't believe I've seen it associated with WinForms or ASP.NET... I can't see how that would matter, but maybe there's a relationship there.
I suspect this is an MS bug. I can't imagine that there's any legitimate condition under which UserPrincipal.Current should cause an AppDomainUnloadedException, but I thought I'd take a shot here on Stackoverflow...

Vb2012 admin permission

I have coded up a cleaner type of program but getting a huge error with permissions ( I think )
The error message is printed out like so.
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
Additional information: Access to the path 'C:\Windows\CSC\v2.0.6' is denied.
And it says that the error part of the code is this line
For Each fi In DirectroyInfos.GetFiles(filter)
But here is the fill block of code.
For Each fi In DirectroyInfos.GetFiles(filter)
Try
file_count = file_count + 1
file_size = CULng(file_size + fi.Length)
FilesToDelete.Add(fi.FullName)
Catch ex As UnauthorizedAccessException
'There's really no pretty way to handle this exception
Catch ex As FileNotFoundException
'There's really no pretty way to handle this exception
End Try
I think it's some sort of permission problem I have windows 7 and have noticed there are a lot of run has admin problems.. I think its trying to remove or gain access to a file which it does not have permission to get .
Is there anyway to fix this? Am I missing something in my coding?
As you said in your question, you don't have write access that file.
Either skip files you don't have access to, or run the application as admin.
There appears to be a limitiation with the win32 api that will skip all files in the folder if you do not have access to one of them.
Check out this solution from Microsoft Connect:
How to: Iterate Through a Directory Tree (C# Programming Guide)