|
My program can be used by a person that has administrator right on his PC system.
|
|
|
|
|
And? That doesn't change the fact that the installer should cover this, not your code. You won't have the opportunity to detect and/or fix every assembly from your code.
|
|
|
|
|
You've got lots of automatic code-checking in the IDE with the references. If you stopped autoloading them and loaded everything using reflection, you'd loose quite some benefits and performance.
Create a "loader"-application; one without any UI at all, that simply checks if all the files mentioned in a text-file are still in the expected locations (and, if you're paranoid, the date of creation, modification and last known hashcode). If all is as expected, Proces .Start your application and exit the loader.
Works better if your users cannot start the main-application directly. There's multiple tricks that you could use to ensure that only the loader-application is used to start your main-executable, like passing a hash of a combination of a known guid and the current date and having the main-app exit if that is incorrect.
If your end-users have administrator-rights, then they can still simply download ILSpy[^] and build their own damn loader
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sorry Friends !
Why you don't just try to answer to my question instead of telling me that what I want to do is wrong ?
If my question has an answer , please help me to find.
About the response , I read somewhere about Appdomain.UnhandledException , AppDomain.FirstChanceException and AppDomain.AssemblyResolve.
But I'm not sure what should I do .
Can you give me a suggestion ?
Thank you !
|
|
|
|
|
Had you put that in your original question, you'd already save some posts.
Can't write a longer answer now, on a lunch-break
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
dilkonika wrote: Why you don't just try to answer to my question I did. You did not mention the AppDomain in your original question. The approach would have been correct for most scenario's, and you could simply show your messagebox. As a warning, I'm not going to post 20 answers in this thread.
I just implemented it, using MSDN[^].
Not very useful. You can only recover if you have the full assembly. If it was there, then it should have already been found. You could only recover if you had all assemblies "twice" on the system, loading them from another location. ..and your users could have deleted them there too, so you just moved your problem to another location, while also doubling the space required.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
There is no real solution to the problem.
The problem is not how your code can recover. It's that fact that if an admin screws up the app THEY are responsible for fixing it, not you.
|
|
|
|
|
I understand that. but I don't want that my application in a such scenario to hang and to be difficult to close it. and of course I want a good messaging behavior to inform the user about what is happening.
|
|
|
|
|
dilkonika wrote: but I don't want that my application in a such scenario to hang and to be
difficult to close it. and of course I want a good messaging behavior to inform
the user about what is happening. That is done using a loader, as explained. I've used the principle before, for an app that needed certification and one of the requirements was to ensure that the files were "as expected". It should recognize "any tampering". Easy with a loader and some hashing.
dilkonika wrote: About the response , I read somewhere about If you're only interested in a single kind of solution, please add it to the starting-post. If possible, with a hyperlink! Now, since you're not going to change your mind even if I say you cannot guarantee that your backups are not equally corrupted, here's your personalized example;
- Create a NEW solution, add a console-project
- Add a class-library and call it "ClassLibrary1".
Edit the class in the classlibrary to look like below;
namespace ClassLibrary1
{
public static class Class1
{
public static string Property1 { get { return "Hello From Class1"; } }
}
} Go to the console-app, and change the Program.cs to below;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += currentAppDomain_AssemblyResolve;
externalTest();
Console.ReadLine();
}
static System.Reflection.Assembly currentAppDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
Console.WriteLine("Assembly Resolve {0}", args.Name);
return AppDomain.CurrentDomain.Load(File.ReadAllBytes(@"D:\Projects\ConsoleApplication8\ClassLibrary1\bin\Debug\Copy of ClassLibrary1.dll"));
}
static void externalTest()
{
Console.WriteLine(ClassLibrary1.Class1.Property1);
}
}
}
- Change the path in the above code to your own local folder.
- Put a reference from the Console-app to ClassLibrary1.
- Build.
- Make a copy of the file "ClassLibrary1.dll", rename it to "Copy of ClassLibrary1.dll" (but keep it in that folder, otherwise you'd need to rebuild to update the folder-location in the code)
- Remove the file "ClassLibrary1.dll" from the debug-folders from BOTH projects.
- Right-click on the project, choose "Unload"
- Hit F5 key. It'll say the static linked file ain't there. Ignore it and run the last build, there's no updated code anyway.
- You'll be taken into the debugger and can see how resolving works.
DO read MSDN on the topic, as it contains some things that you will NEED. One particular warning I'd like to point out;
The event handler can return a different version of the assembly than the version that was requested.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Am working on a project, and I create this screen saver, I use streamer to display the file from note pad, and I want to use a timer so d text can randomizze, but I don't know hw to do it, the one I did is not displaying anything on the form.. I need help please..
|
|
|
|
|
|
Hi guys,
I'm trying to find a way to get the beat from an audio input (physical input on the sound card, not playing a file).
I would like something as basic as having something like a picturebox blinking to the rhythm of the music, do a show/hide or color change black/red, or any other change following the beat. From this I can find my way to do what I need.
I was thinking this could be easy but it seems to be harder than I thought
Thank you for your help.
Vince.
|
|
|
|
|
MBV-Media wrote: I was thinking this could be easy but it seems to be harder than I thought Live audio-access is rather terribly hard, and requires DirectX.
There's an example using C# here on CodeProject; VolumeMeter (Managed DirectX)[^]. Didn't find any VB-specific example though.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you for the info.
I'll have a look at this example and see if I can do something with it... My C# knowledge is quite basic so I will be hard
Thank you anyway...
|
|
|
|
|
I have a vb.net 2013 project.
I have a form with a lot's of controls. Everything was working perfectly.
But at some point , I don't know what I have done , but the Form.Shown event doesn't fire anymore. The form is open correctly and everything works , except that Event.
I delete and recreated again this event , but doesn't work.
what may be the cause and what I should do to fix this ?
Thank you !
|
|
|
|
|
Do you mean it doesn't fire ever? Or only the first time the form is shown and then not fired after that
|
|
|
|
|
I mean doesn't fire ever.
|
|
|
|
|
Does your Shown event handler definitely have Handles MyBase.Shown after it?
|
|
|
|
|
Of course.
Was working before.
I think I found that the cause of the problem is this line of code in Load event :
Application.AddMessageFilter(filter1)
where filter1 is a IMessageFilter.
This filter prevent users clicking on a specific form's area when a condition is true. When I remove this line of code , the shown event is fired.
But what has to do this with a form shown ???!!! And why on other forms ( where I have also exactly this line of code ) everything is working perfectly ?
|
|
|
|
|
Post the code for your IMessageFilter implementation.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Imports System.Windows.Forms
Public Delegate Sub InsideDelegate(ByRef value As Boolean)
Public Class MyMessageFilter
Implements IMessageFilter
Public Event Inside As InsideDelegate
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_LBUTTONUP As Integer = &H202
Private Const WM_PAINT As Integer = &HF
Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
If m.Msg = WM_PAINT Then
Return False
End If
Return OnInside()
End Function
Private Function OnInside() As Boolean
Dim _inside As Boolean = True
If InsideEvent IsNot Nothing Then
InsideEvent(_inside)
End If
Return _inside
End Function
End Class
|
|
|
|
|
So either InsideEvent is Nothing , or it's setting the parameter to True , and your IMessageFilter is cancelling every message except WM_PAINT .
You've declared constants for WM_LBUTTONDOWN and WM_LBUTTONUP ; did you intend to test for and cancel those specific messages?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
yes , I was thinking to test something before.
|
|
|
|
|
|
Yes - don't cancel every message sent to your form.
Most Windows Forms events are raised in response to window messages. If you cancel all messages being sent to the form, then you shouldn't be surprised when things stop working as expected.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|