So I've been stuck on this error for a good week now, and it has been very frustrating
(Impossible to load the file or assembly 'Audio.Default.Switcher.Wrapper.dll' or one of its dependencies. The specified module wasn't found)
I'm working with Visual Studio 2017 and I've downloaded the SoundSwitch project, and everything is working perfectly fine. I'm able to run "SoundSwitch" without any errors.
The way the solution works (as I'm able to understand) is that the "SoundSwitch" C# project is the "master" and it has references to "Audio.Default.Switcher.Wrapper" as well as "SoundSwitch.UI.UserControls"
"Audio.Default.Switcher.Wrapper" as a reference to "AudioDefaultSwitcher"
Both "Audio.Default.Switcher.Wrapper" and "AudioDefaultSwitcher" seem to compile as .dll files
"SoundSwitch.UI.UserControls" cannot be started and is used for display stuff I guess
"SoundSwitch" is the only startable project (not counting mine of course)
The K005_test is MY project, I've added it and it has references (only) to "SoundSwitch" and I'm trying to use the functions from the SoundSwitch project inside K005_test. And so far my K005_test project consists only of
Program.cs (where I get the error by the way)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace K005_test
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); //Exception thrown here
}
}
}
Form1.cs (where I put my code for the test)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace K005_test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("This is a test");
var test = SoundSwitch.Model.AppModel.Instance.AvailablePlaybackDevices; //Error this line exists
}
}
}
And when I run my K005_test project, it compiles and runs just fine, except when I click the button Then I get the error I posted above. Also the message box doesn't open.
What I've tried so far :
Flipping everything to "x86" or "Win32", it seems that it might be related a problem with 64bit something
Using references to both "Audio.Default.Switcher.Wrapper.dll" and "SoundSwitch" in K005_test
copy "Audio.Default.Switcher.Wrapper.dll" pretty much everywhere and praying the gods
Trying to understand where it looks for "Audio.Default.Switcher.Wrapper.dll" but I wasn't able to find anything when looking in the exception details
Nothing has helped in any way.
For anybody wondering, I've uploaded my entire project folder here
https://drive.google.com/open?id=1OABjDiZyF0B-1-b15_9lzMrPZ4UpyKqU
Related
Sorry for the title. I don't know how to describe this problem shortly.
My problem is that I have a class-library which has references to other (third party) DLLs.
I need to use this class-library in another project, so I obviously added the .dll of my class-library to my main-project.
When I start my main-project, there's alway an error which says, that a reference (dll) in my class-library cannot be found.
If I add the whole class-library as a project to my projectmap in visual studio and then reference the whole project, this error doesn't occur.
I really don't want to add the whole class-library as a project to every "host"-project I make.
Has anyone an idea why this error occurs when the .dll of the class-library is added, but not when the whole project of the class-library is added as reference?
There must be a solution to get this working even if I don't add the whole library-project as reference. Otherwise it wouldn't make any sense to make a class library, right?
By the way: My class-library contains third-party dlls and the local copy property of the third-party dll is set to true.
Thanks in advance!
Edit:
My goal is to really make the class-library portable, even though it contains third-party libraries. I want to give only the .dll to another pc and use it without adding the whole class-library project every time.
The error is because you're not copying the dll's on the second project, you added a reference to your dll so it get's copied, but not the dll's referenced by your dll, so there are missing libraries.
Or you redistribute the dependencys with your dll or you can embedd the dll's inside your dll as resources and then intercept the assembly load and provide it through a resource: http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
EDIT: IN order to do it inside a dll you need to use an static class and call an static initializer BEFORE using any of the classes which are dependant on other libraries.
Here is an example setup:
-A library called LibraryB which supplies a simple class like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibraryB
{
public class ReferencedClass
{
public int GetIt()
{
return 5;
}
}
}
-A library called LibraryA which references LibraryB and supplies two classes, the initializer and the real class:
Initializer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace LibraryA
{
public static class Initializer
{
public static void Init()
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
if (!args.Name.StartsWith("LibraryB"))
return null;
return Assembly.Load(LibraryA.Properties.Resources.LibraryB);
};
}
}
}
Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibraryA
{
public class RealClass
{
public int DoIt()
{
LibraryB.ReferencedClass cl = new LibraryB.ReferencedClass();
return cl.GetIt();
}
}
}
The LibraryA also has the LibraryB.dll compiled library embedded as a resource.
-A project called Test which only references LibraryA:
using LibraryA;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Initializer.Init();
RealClass c = new RealClass();
Console.WriteLine("From LibraryA: " + c.DoIt());
Console.ReadKey();
}
}
}
If you set-up everithing right and you execute it it will work, remember that if you are doing through visual studio, vs will copy the dll's so to do a real test after compiling all copy the exe and LibraryA and execute, it will work without LibraryB and LibraryB is being used from LibraryA.
I am trying to show a webpage in a form using C#. I am using CefSharp to show the webpage (as I would like to test & learn how it works). But since I have worked only on inbuilt webbrowser, I have no idea how to get started with CefSharp(Finding it difficult to get any tutorials). I tried to write this code which executes but the form shows nothing in it. Where am I going wrong ?
Here is my Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
namespace chrometest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Cef.Initialize(new CefSettings());
var test = new CefSharp.WinForms.ChromiumWebBrowser("http://www.google.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(test);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Edit :
I tried to run the example from https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When I try to build the solution, it shows a dialog box saying "Restoring Nuget Package cef.redist.x64 3.2454.1317" with a progresss bar which takes hell lot of time to complete but never completes and after sometime it hangs.
Please help what should I do to get the example running.
The CefSharp project has a few different examples as part of the main project.
Basic Example using Nuget
https://github.com/cefsharp/CefSharp.MinimalExample
More Advanced Examples
https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When you installed the project using Nuget it should have opened a Readme.txt file, it contains a lot of useful information.
https://github.com/cefsharp/CefSharp/blob/cefsharp/41/NuGet/Readme.txt
In the context of WinForms there's a few tutorials
http://www.codeguru.com/columns/dotnet/if-you-like-it-put-an-html5-ui-on-it.html
http://thechriskent.com/2014/08/18/embedded-chromium-in-winforms/
For those reading this looking for WPF, there's
http://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
http://www.codeproject.com/Articles/887148/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
More Links
https://github.com/cefsharp/CefSharp.Tutorial
http://thechriskent.com/category/net/cefsharp/
I'm trying to use the Process class but it gives me this compiler error every time I do
The name 'Process' does not exist in the current context
I've already added using System.Diagnostics; at the top of my code but I still get this error. Autocomplete wont even recognize the class.
Hear is the code. I've only included the Main method because the rest of the code has nothing to do with the error.
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
public class MainClass
{
static void Main()
{
AIRuntime adam = new AIRuntime("Adam", false);
adam.AIUpdate();
Process.Start(adam.directory); //adam.directory is just a string
}
}
My IDE is Xamarin Studio if it matters.
After web searching and attempts, I found the problem.
To fix this, I manually add a reference to System in my project options instead of just typing using System;. I also need to keep using System.Diagnostics; at the top. It's all in the picture below
Thanks guys for trying to help
Let's say i released the application below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World!","Message Box");
}
}
}
Now here is my questions:
How to find the function of button which is responsible to show
message box after pressing the button with ollydbg?
How to disable the button click ?
Notes:this must be done with ollydbg only. Assume that i don't have access to the code.
A step-by-step example would be greatly appreciated.
Using Olly or IDA is a lot of work for nothing.
Use .NET Reflector for decompilation(there is 14-day trial) and download Reflexil plugin to be able to modify code.
Finding the place should not be too hard since you have decompiled sourcecode.
If you cannot find the place you can try one of these:
Connect reflector to Visual studio
Export source code and just run it from Visual studio
If code is obfuscated I cannot help you there, you just must start playing with it till you defeat obfuscation
With Reflexil addon you can simply delete/modify the function
Why not use IDA? You can "easily" nop out the function.
I have a c# problem. I have created a project called 'classproject' and I have added several forms to project successfully and successfully ran the program, but there is this other windows form that I just added and when I double-clicked on the form, it took me to the code view and brought out this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class demo : Form
{
public demo()
{
InitializeComponent();
}
private void demo_Load(object sender, EventArgs e)
{
}
}
}
Now, my challenge is that the name of the project is meant to show by default after the namespace as in "namespace classproject" instead of "namespace WindowsFormsApplication1". Please can anyone help me out, what am I meant to do because have tried everything possible. Even if I change the name myself its still going to flag error... someone please help me as soon as possible.
I'm not sure exactly what your issue is. If you change the namespace manually in the code to classproject it should be fine. What error are you talking about? You would also need to change the designer code file as well (probably called demo.Designer.cs).
Just a side note as well. Standard naming convention for C# is to use Pascal-case (as in ClassProject).
You must change namespace in ALL files that was generated by Visual Studio. You can do it manually, or just set cursor on "WindowsFormsApplication1", press F2 and enter new name.
Optionaly you can also change namespace in project properties on Application tab - then all new files added to project will also have namespace that you set there.