I'm trying to use the Html Agility Pack with a MonoTouch application, but cannot find a version that will work with it.
I downloaded the latest binaries from CodePlex and I've tried building with every DLL it contains. None will compile when the target is the iPhone.
Adding the .NET 20 library will allow it to compile to the iPhone Simulator, but when switching to the iPhone I get the error:
Error MT2002: Can not resolve reference: System.Diagnostics.TraceListener (MT2002) (MFLPlatinum12)
It seems like others are using HtmlAgilityPack with MonoTouch projects, so any thoughts as to what I'm missing?
Are you compiling from source or using the DLL directly?
You will need to make a new MonoTouch library project and add all the files for it to work.
Using a DLL directly likely won't work, since it was not compiled for MonoTouch.
You have to compile it from code
Download the source
go into
\htmlagilitypack-99964\Branches\1.4.0\HtmlAgilityPack
Edit the csproj change to
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
Save and load
Fix errors
Trace -> Debug
Remove block
if (!SecurityManager.IsGranted(new DnsPermission(PermissionState.Unrestricted)))
{
//do something.... not at full trust
try
{
RegistryKey reg = Registry.ClassesRoot;
reg = reg.OpenSubKey(extension, false);
if (reg != null) contentType = (string)reg.GetValue("", def);
}
catch (Exception)
{
contentType = def;
}
}
Remove block
if (SecurityManager.IsGranted(new RegistryPermission(PermissionState.Unrestricted)))
{
try
{
RegistryKey reg = Registry.ClassesRoot;
reg = reg.OpenSubKey(#"MIME\Database\Content Type\" + contentType, false);
if (reg != null) ext = (string)reg.GetValue("Extension", def);
}
catch (Exception)
{
ext = def;
}
}
Use the dll in the bin/debug folder
Related
I'm trying to use LibvlcSharp on a linux installation (Ubuntu 18.04). I'm following all the instructions, including this one Getting started on LibVLCSharp.Gtk for Linux but my application always crash. It's working perfectly on windows, because there we can add VideoLAN.LibVLC.Windows package, but I couldn't find someting similar for Linux.
My code:
static void Main(string[] args)
{
// Record in a file "record.ts" located in the bin folder next to the app
var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var destination = Path.Combine(currentDirectory, "record.ts");
// Load native libvlc library
Core.Initialize();
using (var libvlc = new LibVLC())
//var libvlc = "/usr/lib/x86_64-linux-gnu/";
using (var mediaPlayer = new MediaPlayer(libvlc))
{
// Redirect log output to the console
libvlc.Log += (sender, e) => Console.WriteLine($"[{e.Level}] {e.Module}:{e.Message}");
// Create new media with HLS link
var urlRadio = "http://transamerica.crossradio.com.br:9126/live.mp3";
var media = new Media(libvlc, urlRadio, FromType.FromLocation);
// Define stream output options.
// In this case stream to a file with the given path and play locally the stream while streaming it.
media.AddOption(":sout=#file{dst=" + destination + "}");
media.AddOption(":sout-keep");
// Start recording
mediaPlayer.Play(media);
Console.WriteLine($"Recording in {destination}");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
The error message:
Unhandled Exception: LibVLCSharp.Shared.VLCException: Failed to perform instanciation on the native side. Make sure you installed the correct VideoLAN.LibVLC.[YourPlatform] package in your platform specific project
at LibVLCSharp.Shared.Internal..ctor(Func1 create, Action1 release)
at RadioRecorderLibVlcSharp.Program.Main(String[] args) in /media/RadioRecorderLibVlcSharp/Program.cs:line 19
Anyone can help me?
thanks
Can you try apt-get install vlc? That seems to help getting all the required plugins/deps on your system (though it will pull vlc 2.x from the official ubuntu rep probably).
I have a test case which validates an XML file.
When using VS2010 with .Net 3.5 framework, the below code works perfectly fine, i am able to load the XML file. My file is location is Source folder of the application.
XmlDocument doc = new XmlDocument();
try
{
doc.Load("Terms_and_Conditions.xml");
XmlNode node;
XmlElement root = doc.DocumentElement;
//Select and display the value of the element.
node = root.SelectSingleNode(NodeSelection);
return node.InnerText;
}
catch (Exception ex)
{
throw ex;
}
Solution Folder:
When I run the same code in .Net 4.6.1, file path resolves to
C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Terms_and_Conditions.xml
Anyone have an idea why this issue with .Net 4.6.1
This happens because your unit tests run in the test runner, which is located in the Common7 folder and not in your projects bin folder. Since you specify a relative path to the xml file, the program will look for the file in the current folder, which is the Common7 folder.
Thanks everyone for the quick help.
Here is how I solved the problem with above link.
XmlDocument doc = new XmlDocument();
try
{
var path = System.IO.Directory.GetParent(System.IO.Directory.GetParent(TestContext.CurrentContext.TestDirectory).ToString());
doc.Load("Terms_and_Conditions.xml");
XmlNode node;
XmlElement root = doc.DocumentElement;
//Select and display the value of the element.
node = root.SelectSingleNode(NodeSelection);
return node.InnerText;
}
catch (Exception ex)
{
throw ex;
}
With the following code:
static void Main()
{
try
{
var context = uno.util.Bootstrap.bootstrap();
}
catch (Exception ex)
{
Console.WriteLine(ex.toString());
}
}
This code works fine in win 7 but getting "SEH Exception handled by user code External component has thrown an exception".
Lastest Version:Libreoffice 5.0.3.2..Please help me to resolve this problem immediately.
Look the response of another topic:
Bootstrap Uno API LibreOffice exception
var unoPath = #"C:\Program Files\LibreOffice 5\program"
// when running 32-bit LibreOffice on a 64-bit system, the path will be in Program Files (x86)
// var unoPath = #"C:\Program Files (x86)\LibreOffice 5\program"
SetEnvironmentVariable("UNO_PATH", unoPath, EnvironmentVariableTarget.Process);
SetEnvironmentVariable("PATH", GetEnvironmentVariable("PATH") + #";" + unoPath, EnvironmentVariableTarget.Process);````
Accessing a string created by an Error's getStackTrace function is resulting in very unusual behaviour in the FlashDevelop IDE.
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function Main():void
{
print("Start");
var err:Error = new Error();
var stack:String = err.getStackTrace();
print(stack);
// also occurs when this is replaced with stack.length or stack[0]
print("End");
}
private function print(input:*):void
{
trace(input);
trace("---");
}
}
}
When run in flash CS4 that outputs
Start
---
Error
at Main()
---
End
---
But when run in FlashDevelop (replacing trace() with FlashConnect.trace()) it outputs
Start
---
Is that a bug, or is it FlashDevelop handling errors in a different way intentionally?
If it is the latter is there a workaround to access the stacktrace of an error?
I managed to fix this by switching to using a dubugging version of the flash player, i hope this helps anyone else with this problem.
instructions for specifying a debug player
Make sure you are compiling in Debug configuration and you may have to enable (set True) "Verbose Stack Trace" in your Project Properties > Compiler Options
I hooked native api ZwCreateFile, and wdk doc says windows use ZwCreateFile to create or open a directory. I can detect the operation of opening testdir, but i failed to stop the open directory operation.
My code of my own FakeZwCreateFile like this:
NTSTATUS FakeZwOpenFile(
OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG ShareAccess,
IN ULONG OpenOptions
)
{
NTSTATUS rtStatus = STATUS_SUCCESS;
UNICODE_STRING test = RTL_CONSTANT_STRING(L"\\??\\c:\\testdir");
if (!RtlCompareUnicodeString(ObjectAttributes->ObjectName, &test, TRUE))
{
DbgPrint("%wZ\n", &test);
FileHandle = NULL;
IoStatusBlock->Status = rtStatus = STATUS_ACCESS_DENIED;
goto exit;
}
Orig:
OrigZwOpenFile = (NTOPENFILE)oldServiceAddr[SYSTEM_INDEX(ZwOpenFile)];
rtStatus = OrigZwOpenFile(
FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
ShareAccess,
OpenOptions
);
exit:
return rtStatus;
}
Why i failed to stop opening the c:\testdir directory?? And what shoud i do to intercept the operations of creating new folders????
In this case is better to use File System Filter Drivers instead of SSDT hooking, Because FS Filter Drivers work correctly in 64Bit version of windows but SSDT only can use in 32Bit (If you can bypass windows Patch Guard then you can use SSDT hook in 32Bit) !