0

How my app errors. It will just show an Error MessageBox saying "There were build errors" on Windows 8.1 and older, but on Windows 10 it just shows nothing.

1

How can I make it so when my app loads and lets say I get an error right when it loads because of a COM Component DLL not being found, How can I use a Try Catch block to detect that and then maybe display a MessageBox and maybe Me.Close() e.t.c

I tried putting the Try and Catch Block before the InitializeComponents Sub and it worked but it made the WPF Designer not work.

2

  • Please paste your code sample in as text, not a screenshot. This is a build error. It says so right in the error message that you chose to hide in an animated screenshot. It's not a runtime error. A try-catch in your code can't do anything about a build error because if the code does not build, it cannot run – 15ee8f99-57ff-4f92-890c-b56153 Apr 25 '16 at 17:23
  • @EdPlunkett Yeah thats why im trying to Handle the error somewhat as not everyone will have VLC installed for the .dll to load so how can I handle it and perhaps download and open a VLC Setup file like a try catch would normally work but idk –  Apr 25 '16 at 17:25
  • It sounds like the question you want to ask is how to write a VB.NET application which uses a DLL that may not be present on the host machine. [You need to load the VLC DLL dynamically](http://stackoverflow.com/questions/2359918/net-dynamically-load-dll). But first, you need to find out what a build error is. – 15ee8f99-57ff-4f92-890c-b56153 Apr 25 '16 at 17:33
  • You're still struggling with [this issue](http://stackoverflow.com/questions/36808387/vb-net-embed-com-components), is that it? Are you saying you want the application to be able to run without VLC installed? Do you understand that if VLC is not installed, your application cannot do anything that uses VLC? – 15ee8f99-57ff-4f92-890c-b56153 Apr 25 '16 at 17:36
  • You cannot catch build errors in your code, as they are generated _before_ your code is fully compiled. You could however make sure you compile your application on a machine containing all necessary references, then make the app handle the _Application Startup_ event and check if those references are present (i.e. try to load them and wrap the load attempt in a Try-Catch block). – Visual Vincent Apr 25 '16 at 17:42
  • @EdPlunkett Yes thats why im trying to use a try catch block to check if they are there and if there not then download and open the VLC setup file. But how? –  Apr 26 '16 at 16:49
  • @VisualVincent Makes sense about the build bit but how do I handle the Startup Event? –  Apr 26 '16 at 16:50
  • @ShinyMK You don't listen. Bye. – 15ee8f99-57ff-4f92-890c-b56153 Apr 26 '16 at 16:52
  • Press the `Application Events` button in the Project Properties. When in that file you can find the event under the event list. --- I have written dll-files from the application's resources in the `Startup` event before. Even though those dlls where set to `CopyLocal` this should still work with other dlls. Also, what happens if you copy all necessary files along with your .exe? – Visual Vincent Apr 26 '16 at 17:18
  • @VisualVincent You need to understand that like were loading a file called axvlc.dll and like its trying to load some other dll files in VLC's Install Directory inside the Plugins folder. So like no matter what and no matter how I reference the dll's it will still try to use the dll's in VLC's install directory so no matter how I load the DLL's it will just not work. So like I just wanna make a try catch block so that if an error occurs when they open the app it will execute code which will be a messagebox etc but how? I dont want to reference dll;s etc as it wont work I know it wont. –  Apr 26 '16 at 18:07
  • Well on your previous question you've got a comment from Hans with a link to the VLAN website explaining how to install it yourself... If you yet want to display an error, you could handle the [**AppDomain.UnhandledException event**](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx) and check if the exception is of type (for example) `FileNotFoundException`. – Visual Vincent Apr 26 '16 at 18:52
  • @VisualVincent Wait so your saying I can somehow embed VLC itself into my application? Cause thats what I ultimately want I just have no idea how to do it on VB.NET Any chance you can explain it in a bit more detail then Hans? –  Apr 26 '16 at 19:27
  • No I can't explain it further. And no, you can embed _the files required for installation_ and then (according to the VLAN Wiki) install that. – Visual Vincent Apr 26 '16 at 19:33
  • @VisualVincent Oh I see, So your saying embed the files as a resource in my app then somehow extract the files into Program Files? Would using regsvr32 actually be needed if I do that? –  Apr 26 '16 at 19:38
  • That's what I've said _before_. I don't know where to extract the installation files, you are supposed to create a .cab-file of it. Just read the link Hans gave you! – Visual Vincent Apr 26 '16 at 19:39
  • @VisualVincent Hmm so I need to make my own .cab file? Strange as I look at this link about packing them: https://msdn.microsoft.com/en-us/library/aa751974(v=vs.85).aspx and it seems the CABSDK isnt even able to be downloaded anymore so im super confused –  Apr 26 '16 at 19:57
  • There are other utilities out there you know, but according to [this SO answer](http://stackoverflow.com/a/3367438/3740093) it has just been replaced and is now integrated in Windows. – Visual Vincent Apr 26 '16 at 20:04
  • @VisualVincent Oh nice, Didnt know that your really helping out lol, Im gonna try get this CAB file made but can you explain, Once I have it made what do I do with it? I read the link from hans but it doesnt really say anything else apart from building it. –  Apr 26 '16 at 20:06
  • Oh wait, it appears according to the Wiki that this is for when using VLC in webpages (making the web browser automatically install it)... But what if you take the .dlls mentioned in the Wiki and run them through `regsvr32.exe `? **EDIT:** Apparently it's only `axvlc.dll`. – Visual Vincent Apr 26 '16 at 20:12
  • @VisualVincent Doesnt seem to do anything, Already tested this before its weird like when I drag and drop the VLC Control it seems its ALWAYS trying to get the .dll files from VLC's install folder so again im just trying to find a way to just put the files there if they arent there already you know? –  Apr 26 '16 at 20:18
  • And no it needs axvlc.dll libvlc.dll and libvlccore.dll and it also needs EVERYTHING in the Plugins folder. (I tested) –  Apr 26 '16 at 20:19
  • @VisualVincent Weird I guess whatever step 3 was on that Codeproject tutorial worked for him :/ –  Apr 26 '16 at 20:20
  • But at design-time it doesn't matter where it tries to get them from (by the way how can you tell?). It shouldn't look there when compiled. [Re-added link from deleted comment](http://stackoverflow.com/a/10386056/3740093). – Visual Vincent Apr 26 '16 at 20:20
  • @VisualVincent Because if I compile it when I have VLC installed, Then go onto ProgramFiles(x86)/VideoLAN/VLC and rename VLC folder to anything the app wont open because of the COM exception (FIleNotFound) then if I rename it back to VLC and open it works fine. –  Apr 26 '16 at 20:22
  • @VisualVincent Would it be any help if I send you the full Source Code? (Just dont release it to the public as I dont want its source public yet) –  Apr 26 '16 at 20:24
  • That's because it's registered in the Program Files directory _on your computer_. Your app looks there because Windows instructs it to. Running `regsvr32 /u ` to uninstall and then `regsvr32 /s ` should change the path. – Visual Vincent Apr 26 '16 at 20:25
  • @VisualVincent Really confused like /u is to uninstall the DLL but whats /s and am I uninstalling the one in VLC's Directory and installing the one next to the EXE's path? –  Apr 26 '16 at 20:27
  • You're installing where you have the new dll (preferably somewhere global like System32, but your .exe folder works too). -- You can send it if you'd like but I cannot look at it until tomorrow (UTC +2), and I guarantee that I will only use your code in purpose to help you and will not release it anywhere else. You can find my email if you go to my website from my Stack Overflow profile, and then in under the "Support" section. – Visual Vincent Apr 26 '16 at 20:28
  • Also, [**the archived version of the CodeProject post**](http://web.archive.org/web/20120304023434/http://www.codeproject.com/Questions/163016/How-to-embed-VLC-control-in-c-net-windows-applicat) --- and [**Regsvr32 command line parameters**](https://technet.microsoft.com/sv-se/library/bb490985.aspx). – Visual Vincent Apr 26 '16 at 20:30
  • @VisualVincent Yeah that isnt really helpful as I tought it was, Seems like it was just showing how to put it into the WPF, Like If I rename it to VLC1 so that it think i dont have it installed and then try to register the DLL I just get this error: https://i.gyazo.com/1d6de25a8d0ad1b902fc49a6044fc2fd.png –  Apr 26 '16 at 20:36
  • Ok so it doesnt error if I remove /i it registers fine. But it doesnt seem to make a difference. Still doesnt work. –  Apr 26 '16 at 20:42
  • Hmmh. Well I am not able to do anything more tonight. If you want to send me the project I can test it a little bit tomorrow when I get the time. – Visual Vincent Apr 26 '16 at 20:46
  • Yes, but delete that comment please (moderators might do so eventually too). It unfortunately seems to not be very appreciated on Stack Overflow to share [private] contact information :/. (And besides I don't want eventual spam either :p) – Visual Vincent Apr 26 '16 at 21:08
  • Could a moderator clear chat? Its way too long. Anyway I decided to look at VLC.DotNet and I mean, It works kinda but its very unstable. If I "Stop()" and "SetMedia()" then "Play()" after I already played something it just wont work for some streams its really buggy. The reason I wanted to use it was because if you look they allow you to add a LibraryDirectory so I could just put the main dll files in a folder and set that folder on it and it would work which is basically what I need but I cant get working with the standalone ActiveX VLC any ideas? –  Apr 27 '16 at 01:57

0 Answers0