i got this errors
Error 1 The type 'System.Data.SqlServerCe.SqlCeTransaction' is defined in an assembly is not referenced That. You Must add a reference to assembly 'System.Data.SqlServerCe, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91'.
WHERE DO I DOWNLOAD VERSION 4.0.0.0? I didn't find it.
Error 2 The type 'System.Data.SqlServerCe.SqlCeConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.
same problem..
Error 3 The best overloaded method match for 'ErikEJ.SqlCe.SqlCeBulkCopy.WriteToServer (System.Data.DataTable)' Some invalid arguments have
overloaded? only i want to use it :s
Error 88 The best overloaded method match for 'ErikEJ.SqlCe.SqlCeBulkCopy.WriteToServer(System.Data.DataTable)' has some invalid arguments
?? it DOES allow datatable . i dont understand it..
Error 94 Argument '1': cannot convert from 'System.Data.DataTable [c:\Program Files\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\System.Data.dll]' to 'System.Data.DataTable []'
convert to datatable[]?? what?
well this is my method code.
private void DoBulkCopy(bool keepNulls, System.Data.DataTable tabla, string nombretabla)
{
if (tabla.Rows.Count > 0)
{
ErikEJ.SqlCe.SqlCeBulkCopyOptions options = new ErikEJ.SqlCe.SqlCeBulkCopyOptions();
if (keepNulls)
{
options = options |= ErikEJ.SqlCe.SqlCeBulkCopyOptions.KeepNulls;
}
//using (SqlCeBulkCopy bc = new SqlCeBulkCopy(connectionString, options))
using (SqlCeBulkCopy bc = new SqlCeBulkCopy(Resco.Data.Database.Instance.ConnectionString,options))
{
bc.DestinationTableName = nombretabla;
try
{
bc.WriteToServer(tabla);
}
catch(Exception ex) { }
}
}
}
Easy way -> install to project using Package Manager Console.
PM> Install-Package ErikEJ.SqlCeBulkCopy
See http://nuget.org/packages/ErikEJ.SqlCeBulkCopy
Related
public void Launch()
{
if (LinkedInstance != null) return;
LinkedInstance = new OrderInstance(ServiceLocation, Algorithm, MaxPrice, Limit, PoolData, ID, StartingPrice, StartingAmount);
if (HandlerDLL.Length > 0)
{
try
{
Assembly ASS = Assembly.LoadFrom(HandlerDLL);
Type T = ASS.GetType("HandlerClass");
HandlerMethod = T.GetMethod("HandleOrder");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
This code will open an assembly based on file name and assign HandlerMethod with T.GetMethod.
The thing is I do not want to create a dll file.
I want to do this with a project file in the solution.
The type of HandlerMethod is this
private MethodInfo HandlerMethod;
So How do I assign HandlerMethod to point to a method in a class I have.
It just happens that the name of the assembly of sample Handler is Handler Example
So I tried to change the code to this
Assembly ASS = Assembly.LoadFrom("HandlerExample");
Type T = ASS.GetType("HandlerClass");
HandlerMethod = T.GetMethod("HandleOrder");
It simply cause exception.
How do I arrange that ASS would refer to the dll file that is in another project in the solution. I want minimal code change.
If the method is present in some other project then you can either add a reference to that project and use the method directly, or if you want to use reflection, then Assembly ASS = Assembly.LoadFrom(HandlerDLL); will do the job that you are already using.
If the class is in the same project then you can use Assembly ASS = Assembly.GetExecutingAssembly(); and in this case you don't need to provide dll name.
Note: Though it is not mentioned by OP what language he is using, but the code looks like c# to me.
When moving a project into .Net Core, AddHeader throws an error:
Error CS1061 'HttpResponse' does not contain a definition for
'AddHeader' and no extension method 'AddHeader' accepting a first
argument of type 'HttpResponse' could be found (are you missing a
using directive or an assembly reference?) .NETCoreApp,Version=v1.0
The answer is to instead do the following (without using AddHeader) :
Response.Headers["key-goes-here"] = "value-goes-here";
Checkout
Examples:
string combineValue = httpContext.Request.Headers["header1];
if (string.IsNullOrEmpty(combineValue)) // ...
var values = httpContext.Request.Headers["header1"];
if (StringValues.IsNullOrEmpty(values)) // ...
httpContext.Response.Headers["CustomHeader1"] = "singleValue";
httpContext.Response.Headers["CustomHeader2"] = new[] { "firstValue", "secondValue" };
Or you can just say:
Response.Headers.Add("key", "value");
I'm using NAudio (1.7.3.0) and NAudio.lame ( 1.0.3.3048 ) to convert Wav to Mp3 audio format.
My code(calling assembly) is strongly named , VS2015 complains that Naudio/NAudioLame dlls should be strongly named too, so I did singed Naudio dlls with strong name. now Unfortunatley I'm build error as
Note : I have strongly named both(Naudio) dlls.
Here is the code.
try
{
string filePath = #"D:\Lame\Wav\25mb.wav";
string outputPath = #"D:\Lame\mp3\25mb.mp3";
using (WaveFileReader wavReader = new WaveFileReader(filePath))
using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(wavReader))
using (LameMP3FileWriter fileWriter = new LameMP3FileWriter(outputPath, pcm.WaveFormat, LAMEPreset.VBR_90))
{
pcm.CopyTo(fileWriter);
}
MessageBox.Show("Converted !");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Build error on : LameMP3FileWriter(outputPath, pcm.WaveFormat, LAMEPreset.VBR_90)
Error : The type 'WaveFormat' is defined in an assembly that is not referenced. You must add a reference to assembly 'NAudio, Version=1.7.3.0, Culture=neutral, PublicKeyToken=null.
Any help is appreciate !
You need to build your strongly named NAudio first, and then when you build NAudio.Lame, make sure it references your strongly named NAudio dll
I need to convert this code from C# to VB. I'm not sure of the proper syntax.
C#
[XcoWorkerExtension(Optional = new Type[] { typeof(Subscribe<OnNewsArrived>) })]
private readonly XcoPublisher<OnNewsArrived> publisher = new XcoPublisher<OnNewsArrived>();
This is what I've come up with in VB:
<XcoWorkerExtension([Optional]:=New Type() {GetType(Subscribe(Of OnNewsArrived))})> _
Private ReadOnly publisher As New XcoPublisher(Of OnNewsArrived)()
The C# version runs fine but when I try to run the VB version I'm getting this exception:
System.IO.FileLoadException was unhandled
Message=The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Source=mscorlib
The exception is generated at the first line of this sub:
internal XcoWorkerExtensionAttribute Get_worker_extension_attribute(FieldInfo field)
{
object[] fieldAttrs = field.GetCustomAttributes(typeof(XcoWorkerExtensionAttribute), false);
object[] classAttrs = field.FieldType.GetCustomAttributes(typeof(XcoWorkerExtensionAttribute), false);
if (fieldAttrs.Length > 0 && classAttrs.Length == 0)
throw new XcoWorkerException("A field can only be marked with the XcoWorkerExtension attribute when its type is also marked with this attribute");
if (fieldAttrs.Length > 0)
return (XcoWorkerExtensionAttribute)fieldAttrs[0];
if (classAttrs.Length > 0)
return (XcoWorkerExtensionAttribute)classAttrs[0];
return null;
}
Sorry for giving a "meta answer".
For small conversions like this, Reflector is a nice tool if you are unsure about syntax and/or results.
Possibilities of use:
Compile in C#, and decompile to VB.Net.
Compile in VB.Net, compare to original
C# to VB Converter
Worked for one of my projects, though I suspect there are a few things that will make it unhappy. And you as well.
How can I get the list of all DLL dependencies of a given DLL or EXE file?
In other words, I'd like to do the same as the "Dependency walker" tool, but programmatically.
What is the Windows (ideally .NET) API for that?
You can use EnumProcessModules function. Managed API like kaanbardak suggested won't give you a list of native modules.
For example see this page on MSDN
If you need to statically analyze your dll you have to dig into PE format and learn about import tables. See this excellent tutorial for details.
NOTE: Based on the comments from the post below, I suppose this might miss unmanaged dependencies as well because it relies on reflection.
Here is a small c# program written by Jon Skeet from bytes.com on a .NET Dependency Walker
using System;
using System.Reflection;
using System.Collections;
public class DependencyReporter
{
static void Main(string[] args)
{
//change this line if you only need to run the code one:
string dllToCheck = #"";
try
{
if (args.Length == 0)
{
if (!String.IsNullOrEmpty(dllToCheck))
{
args = new string[] { dllToCheck };
}
else
{
Console.WriteLine
("Usage: DependencyReporter <assembly1> [assembly2 ...]");
}
}
Hashtable alreadyLoaded = new Hashtable();
foreach (string name in args)
{
Assembly assm = Assembly.LoadFrom(name);
DumpAssembly(assm, alreadyLoaded, 0);
}
}
catch (Exception e)
{
DumpError(e);
}
Console.WriteLine("\nPress any key to continue...");
Console.ReadKey();
}
static void DumpAssembly(Assembly assm, Hashtable alreadyLoaded, int indent)
{
Console.Write(new String(' ', indent));
AssemblyName fqn = assm.GetName();
if (alreadyLoaded.Contains(fqn.FullName))
{
Console.WriteLine("[{0}:{1}]", fqn.Name, fqn.Version);
return;
}
alreadyLoaded[fqn.FullName] = fqn.FullName;
Console.WriteLine(fqn.Name + ":" + fqn.Version);
foreach (AssemblyName name in assm.GetReferencedAssemblies())
{
try
{
Assembly referenced = Assembly.Load(name);
DumpAssembly(referenced, alreadyLoaded, indent + 2);
}
catch (Exception e)
{
DumpError(e);
}
}
}
static void DumpError(Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: {0}", e.Message);
Console.WriteLine();
Console.ResetColor();
}
}
To get native module dependencies, I believe it should be ok to get it from the PE file's import table, here are 2 links which explain that in-depth:
http://msdn.microsoft.com/en-us/magazine/bb985992.aspx
http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
To get .NET dependencies, we can use .NET's API, like Assembly.Load.
To get a .NET module's all dependencies, How about combine the 2 ways - .NET assemblies are just PE file with meta data.
While this question already has an accepted answer, the documentation referenced in the other answers, where not broken, is old. Rather than reading through all of it only to find it doesn't cover differences between Win32 and x64, or other differences, my approach was this:
C:\UnxUtils\usr\local\wbin>strings.exe E:\the-directory-I-wanted-the-info-from\*.dll > E:\TEMP\dll_strings.txt
This allowed me to use Notepad++ or gvim or whatever to search for dlls that were still depending on MS dlls with 120.dll at the end of the dll name so I could find the ones that needed updating.
This could easily be scripted in your favorite language.
Given that my search for this info was with VS 2015 in mind, and this question was the top result for a Google search, I supply this answer that it may perhaps be of use to someone else who comes along looking for the same thing.
To read the DLL's (modules) loaded by a running exe, use the ToolHelp32 functions
Tool help Documentation on MSDN.
Not sure what it will show for a .Net running exe (I've never tried it). But, it does show the full path from where the DLL's were loaded. Often, this was the information I needed when trying to sort out DLL problems. .Net is supposed to have removed the need to use these functions (look up DLL Hell for more information).
If you don't want to load the assembly in your program, you can use DnSpy (https://www.nuget.org/packages/dnSpyLibs):
var assemblyDef = dnlib.DotNet.AssemblyDef.Load("yourDllName.dll");
var dependencies = assemblyDef.ManifestModule.GetAssemblyRefs();
Notice that you have all the infos you can want in the "ManifestModule" property.