I am trying to build an application to grab syslog from ios device.
I am completely new to C# and have no idea on where to start.
I have found library called Manzana, a C# library to obtain device control of ios device.
My problem is I do not know how to load this library or how the calling conventions are.
Is there anyone kind enough to explain what steps i need to take ?
thanks
First of all, I'd recommend you to use a working iTunesMobileDevice C# API.
There are hundred versions of Manzana that are either out of date or include crap code (Non-working DllImports or obsolete methods).
Do not use Manzana, it's outdated and contains crap-code.
I recommend a powerful MobileDevice-Version: (Chinese comments but clean & working code):
Working iTunesMobileDevice C# API
Once you downloaded the source-files (All .cs files), drag them into your IDE's project. Open your main class and make an instance of iPhone.
You need to create 2 event-handlers, Connect & Disconnect
public static void Main(String[] args)
{
iPhone my_device_instance = new iPhone();
my_device_instance.Connect += new ConnectEventHandler(onConnect);
my_device_instance.Disconnect += new ConnectEventHandler(onDisconnect);
Console.WriteLine("Waiting for device...");
System.Threading.Thread.Sleep(-1)
}
static void onConnect(object sender, ConnectEventArgs e)
{
// Do stuff...
}
static void onDisconnect(object sender, ConnectEventArgs e)
{
// Do stuff...
}
Learn the basics of C# and analyse the given source-code.
One more thing: If you want to grab syslog, you need to make use of the class iPhoneFile.
Related
So maybe I am just ignorant, but C# has some lovely functionality with System.Diagnostics.Tracing.EventSource that make writing new event sources super simple. I've got some functionality built up around this convenient api that allows these logs to be processed after ingestion.
All of this however is being moved to powershell and I'm trying to get it working. If I consume a current implementation of a EventSource subclass through dlls everything works as expected. If I try to write a new EventSource subclass purely in powershell, the event stop showing up.
I have researched the googles quite thoroughly and it has become clear to me that this is not a standard approach. (Surprising because it is such a handy chunk of coding) Can anyone help or tell me what I may be doing wrong?
class TestEventSource2 : System.Diagnostics.Tracing.EventSource
{
static [TestEventSource2] $Log = [TestEventSource2]::New()
static [string] $LogName = "its a name"
[void] WriteTestEvent() {
Write-Information "WriteTestEvent"
WriteEvent(1,"Hello world from a powershell test event.")
}
}
$loglog = [TestEventSource2]::Log
$loglog.WriteTestEvent()
I’m trying to use an embedded browser into my WinForms application. I used CefSharp ChromiumWebBrowser, it work perfectly. However, CEFSharp requires the Visual C++ 2013, or the Visual C++ 2008….I think it is a complicated dependency. I'm creating a portable application without the dependency envirenment.
I have found another library, similar CefSharp, also use Chrominum, called ChromiumFX (visit: https://bitbucket.org/chromiumfx/chromiumfx ). The library uses the .Net Framework 3.5 (Default available in Windows 7) , no need to install Visual C++. And it is suitable for my application.
But I don’t find any way to create multi tabs application with this library. Here is what I tried to do:
private void LifeSpanHandler_OnBeforePopup(object sender, CfxOnBeforePopupEventArgs e)
{
e.SetReturnValue(true);
tabPage2.InvokeOnUiThreadIfRequired(() =>
{
ChromiumWebBrowser b = new ChromiumWebBrowser(e.TargetUrl);
b.Dock = DockStyle.Fill;
tabPage2.Controls.Add(b);
});
}
InvokeOnUiThreadIfRequired is an extension method:
public static void InvokeOnUiThreadIfRequired(this Control control, Action action)
{
if (control.InvokeRequired)
{
control.BeginInvoke(action);
}
else
{
action.Invoke();
}
}
But the application error and the program has crashed.
Another thing, when I created a new instance of ChromiumWebBrowser, I want it isolated with another instance, it means do not use the same cookies, sessions with any instance (private browser). In CefSharp, just create a new RequestContext for new instance:
webbrowser.RequestContext = new RequestContext();
But in ChromiumFX, I dont find any way to do that!
Somebody help me? Thank for you help!
My windows 8 app is failing the Certification test:
The app should call the Trim API on its IDXGIDevice3 interface anytime it is about to be suspended.
The link takes me to a C++ page, but I'm using SharpDX. I can only find one example of this mentioned on a post in a book here https://www.packtpub.com/article/integrating-direct3d-xaml-windows81#more
Unfortunately it mentioned a DeviceManager class (from the book I think?) and my SharpDX.DXGI.Device3 is missing. There is a Device1 and Device2 but no 3. Perhaps different version of the library or I'm missing a reference to something else?
So I'm looking for an example of how to call Trim so that the Certification app is happy and it cleans up any graphics objects etc on suspending the app.
void App::OnSuspending(
_In_ Platform::Object^ sender,
_In_ Windows::ApplicationModel::SuspendingEventArgs^ args
)
{
Windows::ApplicationModel::SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
// Save application data
m_exampleDxgiAdapter->Trim();
deferral->Complete();
}
The following example shows how to call Trim() in order to pass the Certification process:
async void OnSuspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
{
var Deferral = e.SuspendingOperation.GetDeferral();
using (var Device = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware, SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport, new[] { SharpDX.Direct3D.FeatureLevel.Level_11_1, SharpDX.Direct3D.FeatureLevel.Level_11_0 }))
using (var Direct3DDevice = Device.QueryInterface<SharpDX.Direct3D11.Device1>())
using (var DxgiDevice3 = Direct3DDevice.QueryInterface<SharpDX.DXGI.Device3>())
DxgiDevice3.Trim();
Deferral.Complete();
}
You must download and use SharpDX Latest Dev Package (which is currently 2.5.1) for SharpDX.DXGI.Device3
SharpDX.DXGI.Device3 is available from latest SharpDX dev package (2.5.1) from the DirectX11_2-winrt assemblies.
This DeviceManager is not part of DirectX API but looks like it is part of the sample from the book. You need to retrieve the Device3 device by "COM-querying" the interface on the original DXGI device (something like deviceManager.Device1.QueryInterface<Device3>();)
I would like to extend the functionality of vbscript with the code I have written in c#. I have written some classes to automate the SAP GUI and would like to use these classes in all the vbscript files I have.
I have hundreds of vbscript files and know it will take years to convert all them to C#. So I think it will be faster to expose my c# classes to vbscript.
Do you know how to do this or know any references online I can study?
I don't know whether you're running your VBScript from the command-line or from within something like Office.
If the former, you could create one or more command-line apps that you can call from any scripting language and into which you pass parameters & action specifiers just like any other command-line tool. (Also consider moving to PowerShell in this case - it exponentially better than VBScript for command-line scripting & has great integration with .NET).
If the latter, you'll likely need to register your C# classes using RegAsm and then create instances of your C# types as per any other COM type. See this post for more details: How do I call .NET code (C#/vb.net) from vbScript?
VB script runs on the client inside the browser run-time.
The only C# solution I am aware of to run inside the browser, is silverlight. It is still just c# though.
You can access c# code from scripting languages like VB- of java-script, by decorating them with the [ScriptableMember] attribute, like so:
/// <summary>
/// Members that can be called from javascript. (or vbscript)
/// </summary>
public sealed class LINEARVIEWER_SL_SCRIPTS {
[ScriptableMember]
public void ChangeNetwork(string pNetworkFilterId, string pNetworkFilter) {
MainViewModel MainVM = (MainViewModel)((MainPage)Application.Current.RootVisual).DataContext;
long SectionID;
if (long.TryParse(pNetworkFilterId, out SectionID) == false) {
throw new FormatException("'" + pNetworkFilterId + "' not a valid section / network ID.");
}
MainVM.RoadFilterViewModel.SelectSectionAsync(SectionID, /* completed handler = */ null);
}
}
You have to register these classes when the silverligh (c#) application starts up, like so:
private void Application_Startup(object sender, StartupEventArgs e) {
...
HtmlPage.RegisterScriptableObject("LINEARVIEWER_SL_SCRIPTS", new LINEARVIEWER_SL_SCRIPTS());
}
From the java (or vb) script, you can then simply call those methods like so:
function DoAddToLIV(pNetworkFilterId, pNetworkFilter) {
...
gObjLIV.Content.LINEARVIEWER_SL_SCRIPTS.ChangeNetwork(pNetworkFilterId, pNetworkFilter);
...
}
where gObjLIB.Content is the id of the silverlight object inside the html page.
var gObjLIV = null;
function onSilverlightPluginLoaded(sender, args) {
gObjLIV = sender.getHost();
}
You can hook that function to the silverlight object in the html of ASPX page, using this parameter:
<param name="onLoad" value="onSilverlightPluginLoaded" />
Let me know if I missed anything or if you need more examples. I don't mind.
IronRuby and VS2010 noob question:
I'm trying to do a spike to test the feasibility of interop between a C# project and an existing RubyGem rather than re-invent that particular wheel in .net. I've downloaded and installed IronRuby and the RubyGems package, as well as the gem I'd ultimately like to use.
Running .rb files or working in the iirb Ruby console is without problems. I can load the both the RubyGems package, and the gem itself and use it, so, at least for that use case, my environment is set up correctly.
However, when I try to do the same sort of thing from within a C# (4.0) console app, it complains about the very first line:
require 'RubyGems'
With the error:
no such file to load -- rubygems
My Console app looks like this:
using System;
using IronRuby;
namespace RubyInteropSpike
{
class Program
{
static void Main(string[] args)
{
var runtime = Ruby.CreateRuntime();
var scope = runtime.ExecuteFile("test.rb");
Console.ReadKey();
}
}
}
Removing the dependencies and just doing some basic self-contained Ruby stuff works fine, but including any kind of 'requires' statement seems to cause it to fail.
I'm hoping that I just need to pass some additional information (paths, etc) to the ruby runtime when I create it, and really hoping that this isn't some kind of limitation, because that would make me sad.
Short answer: Yes, this will work how you want it to.You need to use the engine's SetSearchPaths method to do what you wish.
A more complete example
(Assumes you loaded your IronRuby to C:\IronRubyRC2 as the root install dir)
var engine = IronRuby.Ruby.CreateEngine();
engine.SetSearchPaths(new[] {
#"C:\IronRubyRC2\Lib\ironruby",
#"C:\IronRubyRC2\Lib\ruby\1.8",
#"C:\IronRubyRC2\Lib\ruby\site_ruby\1.8"
});
engine.Execute("require 'rubygems'"); // without SetSearchPaths, you get a LoadError
/*
engine.Execute("require 'restclient'"); // install through igem, then check with igem list
engine.Execute("puts RestClient.get('http://localhost/').body");
*/
Console.ReadKey();