Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all 1429 articles
Browse latest View live

How to validate menu items?

$
0
0

I'm trying to validate menu items (i.e. enable / disable them) in my Xamarin Mac project but I cannot get my validateMenuItem method to be called:

               [Export("validateMenuItem")]
               public bool validateMenuItem(NSMenuItem menuItem)
            {
                // logic to enable / disable goes here...

                // default to true
                return true;
            }

I have placed this method in MainController.cs, MainWindow.cs and AppDelegate.cs. The menu Actions are defined in AppDelegate.h. Auto Enables Items is set to true. The Mac Developer library says "the object implementing this method (validateMenuItem) must be the target of menuItem". The menu actions all work fine. I must be doing something wrong...but what? I'd appreciate any help.

-Bill


How Can I Clear Selection of NSComboBox ?

$
0
0

We can clear the selection of ComboBox coding this:

combobox.SelectedIndex=-1;

with C# on Windows. However, it this coding methodology cannot run for macOS NSComboBox. What is the real solution ? Thanks.

Mac Certificates - Not able to sign the app with Developer ID application certificate

$
0
0

We are planning to distribute our MAC app out of app store. We face some problem in signing the app.
We created Developer ID application and developer ID Distribution certificates. We have given these certificates in MAC signing options. Here we have checked ‘Sign the application Bundle’ and given the identity as Developer ID Application and selected the correct Provisioning profile. Then we have selected the ‘Sign Installer Package’ option and given the Developer ID installer. We are getting a dialog (Provisioning Profile) with a message 'No Valid Provisioning Profile Found' when we click on Sign and Distribute button while archive and Publishing.

We are able to sign with Mac App Distribution certificate. But we are not able to sign with Developer ID Application and Developer ID installer certificates (For outside app store) . Please help us to resolve this issue.

How Can I Add Item to macOS NSComboBox with Xamarin & C#?

$
0
0

I'm using Xamarin & C# to develop a macOS application. I have a NSComboBox in the storyboard. It have an outlet, so i can access to it successfully.

I have an data context which populated in a list like this:

public static List<string> bloomTypes_EN = new List<string>(new string[] {
        "Cognitive Memory",
        "Cognitive Understanding",
        "Cognitive Practice",
        "Cognitive Analysis",
        "Cognitive Evaluation",
        "Cognitive Generation",
        "Affective Reception",
        "Affective Behavior",
        "Affective Valuing",
        "Affective Organization",
        "Affective Character Making",
        "Psychomotor Perception",
        "Psychomotor Organization",
        "Psychomotor Guided Behavior",
        "Psychomotor Mechanization",
        "Psychomotor Complex Behavior",
        "Psychomotor Harmony",
        "Psychomotor Generation" });

I want add this list into the NSComboBox with Add function:

 if(EarnArea_ComboBox.Count !=  0) // If not empty.
        {
            EarnArea_ComboBox.RemoveAll(); // delete all items.
        }
        else // Empty.
        {
            EarnArea_ComboBox.Add(values.ToArray());
        }

Add functions supports add NSObject[]. Giving string array causes this error:

Error CS1503: Argument 1: cannot convert from 'string[]' to 'Foundation.NSObject[]' (CS1503)

How can I add item to NSComboBox ? Thanks.

Need help with DocumentController

$
0
0

Need help with implementing the DocumentController and delegates.
Struggling to pass a delegate to a method "canCloseDocumentWithDelegate". Can someone please help me convert the objective-c code to C#

ps: ignore error handling

NSArray *documents = [self documents];
if ([documents count] > 0) {
        NSDocument  *lastDocument = [documents lastObject];
        void (^didCloseCallback)(BOOL) = ^void (BOOL didClose) {
            // Some stuff
        }
        [lastDocument canCloseDocumentWithDelegate:self
                               shouldCloseSelector:@selector(document:shouldClose:contextInfo:)
                                       contextInfo:(void *)CFBridgingRetain([didCloseCallback copy])];
    }

Have tried almost everything that google threw me at but not a single reference to calling these API's (like "canCloseDocumentWithDelegate")

Thanks in advance

.abhi

Binding Objective C Lib

$
0
0

I developed an application which wants to bind with Objective c lib (.a file). This application has lots of packages which supports Target framework Xamarin Mac Full. But when I created the binding project it is created as Xamarin Mac Modern. When I changed it to Xamarin Mac Full it shows lots of error, Xamarin.Mac reference is also missing. Please help me on this. How to solve this issue. I am new in Xamarin, so please excuse if anything wrong.

ConfigurationManager.OpenMappedExeConfiguration problem

$
0
0

I'm updating my app to Xamarin.Mac 4.0 and I faced a problem with this code

        public override string GetApplicationSetting(string pSettingName, string pDefaultValue) {
            string result = pDefaultValue;
            pSettingName = pSettingName.Trim().Crypt();

            ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap() { ExeConfigFilename = SettingsFilePath };
            configuration = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);

            KeyValueConfigurationCollection settings = configuration.AppSettings.Settings;

            if (settings.AllKeys.Contains(pSettingName)) {
                result = settings[pSettingName].Value.Trim().Decrypt();
            }
            return result;
        }

This call ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
doesn't create the AppSettings section, and this line configuration.AppSettings returns null, so my app is crashing now.

This code was working fine on the older version of Xamarin.Mac.

How to properly map a DLL name to a native Mac framework

$
0
0

I am trying to use the Chromium Embedded Framework.framework in my Mac app. In my sample .net code, this framework is referenced as libcef.dll. When I call a method on the framework, I get a System.DllNotFound exception. I have looked at DLL maps to map the CEF framework to the expected DLL name and I have the following map but this did not resolve the issue.

<configuration>
       <dllmap dll="libcef" target="/Library/Frameworks/Chromium\ Embedded\ Framework.framework/Chromium Embedded Framework" />
</configuration>

I have also added the framework to my project as a native reference but nor did this resolve the issue.

Does anyone know how I might be able to get around this DllNotFound exception?

The stack trace is this.

System.DllNotFoundException: libcef
at at (wrapper managed-to-native) Xilium.CefGlue.Interop.libcef:api_hash (int)
at Xilium.CefGlue.CefRuntime.CheckVersionByApiHash () [0x00002] in /Users/jlaase/Documents/dev/xilium.cefglue/CefGlue/CefRuntime.cs:106
at Xilium.CefGlue.CefRuntime.CheckVersion () [0x00002] in /Users/jlaase/Documents/dev/xilium.cefglue/CefGlue/CefRuntime.cs:92
at Xilium.CefGlue.CefRuntime.Load () [0x0000c] in /Users/jlaase/Documents/dev/xilium.cefglue/CefGlue/CefRuntime.cs:81
at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2879
at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113
at Demo.CefGlue.AppDelegate+c__async0.MoveNext () [0x00099] in <6839508fd4284d13b86c5e47bd563ec6>:0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at MonoMac.AppKit.AppKitSynchronizationContext+c__AnonStorey0.<>m__0 () [0x00000] in <69849e6b886848f68ef0f56b62fe76aa>:0
at MonoMac.Foundation.NSAsyncActionDispatcher.Apply () [0x00002] in <69849e6b886848f68ef0f56b62fe76aa>:0
at at (wrapper managed-to-native) MonoMac.AppKit.NSApplication:NSApplicationMain (int,string[])
at MonoMac.AppKit.NSApplication.Main (System.String[] args) [0x0003d] in <69849e6b886848f68ef0f56b62fe76aa>:0
at Demo.CefGlue.MainClass.Main (System.String[] args) [0x00006] in <6839508fd4284d13b86c5e47bd563ec6>:0

Thanks,

Josh


Followed sandbox directions, but app still doesn't run as sandboxed

$
0
0

We're looking to get our mature Xamarin Mac application published on the app store, so I've started down the path of finding out what needs to be changed to enable this to happen, and the first step is to attempt to get the app running in 'sandboxed' mode. I've followed this procedure here to the letter:
https://developer.xamarin.com/guides/mac/application_fundamentals/sandboxing/
... but the app still is NOT running as 'sandboxed' (according to Activity Monitor), and it's operation definitely seems normal (i.e. it isn't causing exceptions or problems that I would expect it to cause due to the way we use some local files etc).

One question I have is that in the "Enable the app sandbox" step it instructs "Check both Enable Entitlements and Enable App Sandboxing", however I can't see any "Enable Entitlements" checkbox or option. Is that what I'm missing?

OS and app info:
macOS 10.13.3
VS Community 7.3.3 (build 5)
Xamarin Mac 4.0.0.215
Xcode 9.2 (13772)

Any suggestions as how to work out what the problem is?

Thanks

Mike

Stable Channel: Xamarin.Mac 4.0.0.216, 15.5.5 Servicing Release

Create pkg from visual studio for windows?

$
0
0
Currently I'm having an iOS, Andoid and WPF applications.

I use a Windows machine that is connected to a Mac to build their artifacts (ipa,apk,exe).

When I add a Mac application to the build, without checking the option to create a package, the build passes. Otherwise it fails with a compilation error.

If I can build the Mac application from a Windows device successfully, why can't I create a package as well? Is it a local bug or not yet supported? Will it be supported if so and when?

Thanks.

Sandboxing continued - no way around use of NSDocument to gain read/write access to files?

$
0
0

I just wanted to check this aspect before proceeding with a bunch of code changes. There is this quote in the Sandboxing documents:
"Opening, Saving and Tracking Documents - If you are managing documents using any technology other than NSDocument, you should switch to it because of the built in support for the App Sandbox. NSDocument automatically works with PowerBox and provides support for keeping documents within your sandbox if the user moves them in Finder."

Currently we aren't using NSDocument, but rather are doing 'manual' handling of the particular files our application loads from and saves to (i.e. using File.ReadAllBytes, calling FSOpenSavePanelDelegate etc). I've found that I get an 'unauthorized access exception' in my sandboxed app, even with the "User Selected File" entitlement set to "Read/WriteAccess", when trying to open our files from the user's 'Document' directory. I am guessing this is happening precisely because of us not using NSDocument, and that there isn't any way around rewriting things to use NSDocument, is that correct?

Thanks

Mike

Developer ID Code Signing + Provisioning Profiles not Working (Xamarin.Mac + Code Signing + VS 7.4)

$
0
0

Hi Xamarin,
I'm running into issues where I'm not able to build my project because Xamarin.Mac is not able to find an applicable Provisioning Profile. This worked without issue prior to upgrading to VS7.4.
Here's a screen shot showing that I want to use Developer ID signing (for non-appstore distribution):

Here is the provisioning profile set up on Developer.Apple.com:

And here is a screen shot showing that it is installed:

And here is a screen shot showing the error I get when I try to build:

Am I missing something or is this a VS bug?

CoreWLAN Wifi Password/Passphrase in Xamarin.Mac

$
0
0

It seems that classes such as CWWirelessProfile and CW8021XProfile have been removed from the CoreWLAN namespace leaving just a CWNetworkProfile. But unlike the the 2 deprecated classes, CWNetworkProfile does not have a Password nor a Passphrase property.

Does anybody know how I can programmatically retrieve the Wifi password/passphrase for a CWNetworkProfile?

Thanks

Here's my current environment...

=== Visual Studio Community 2017 for Mac ===

Version 7.3.3 (build 7)
Installation UUID: 52841cf1-dbf0-469c-a714-a263f1d0573b
Runtime:
Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
GTK+ 2.24.23 (Raleigh theme)

Package version: 504010007

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.0.0
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Version: 2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.1.5.0 (Visual Studio Community)
Android SDK: /Users/allan/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
6.0 (API level 23)
7.1 (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 25.0.3

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.2 (13772)
Build 9C40b

=== Xamarin.Mac ===

Version: 4.0.0.216 (Visual Studio Community)

=== Xamarin Inspector ===

Not Installed

=== Xamarin.iOS ===

Version: 11.6.1.4 (Visual Studio Community)
Hash: db807ec9
Branch: xcode9.2
Build date: 2018-01-10 16:45:48-0500

=== Build Information ===

Release ID: 703030007
Git revision: 125911fb4accc4309b2cee5c81c970c7cff9b0e0
Build date: 2018-01-22 17:46:46-05
Xamarin addins: 463e21a6d9d4f6b57f923df376fff093a1dd9404
Build lane: monodevelop-lion-d15-5

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
Thu Jan 11 22:59:40 PST 2018
root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.1

iTunes Connect: i386 libMonoPosixHelper.dylib must be 64-bit starting January 2018

$
0
0

Hello,

When I try to upload the .macOS app of a xamarin.forms Cross-Platform solution to iTunes Connect (Apple macOS App Store), I get this message:

"
1 package(s) were not uploaded because they had problems:
/var/folders/x9/kkvymd5s6zx2f8rhzjxfrxpr0000gn/T/0BA86806-D2FE-446C-AA50-CE4A9411D9A1/1335347427.itmsp - Error Messages:
description length:132696
ERROR ITMS-90240: "Unsupported Architectures. Your executable contained the following disallowed architectures: '[i386 (in dk.eksit.TimeDateCalculator-macOS.pkg/Payload/timeDateCalculator.macOS.app/Contents/MonoBundle/libMonoPosixHelper.dylib)]'. New apps submitted to the Mac App Store must support 64-bit starting January 2018, and Mac app updates and existing apps must support 64-bit starting June 2018."
"

What can I do to solve that problem ?

(It is Visual Studio for Mac version 7.3.3 I'm using)

Best regards,
Eigil


getting Logged in User name from root process

$
0
0

i am having root process which have get the information about the logged in user. the daemon is running as root and need to get the logged user name in xamarin.mac. please help

Is it possible to show Xamarin.Forms page in native Xamarin Cocoa app

$
0
0

I have a native Cocoa App in Xamarin. I have a PCL from other app that contains few pages (like Settings / Login etc).
I want to embed the page inside my NSView

Is it possible (in Beta / Pre-release)

Cannot create Cocoa App

$
0
0

Hi i want to create an application on Mac. I stated to read this topics https:
//blog.xamarin.com/building-your-first-macos-app/
https://developer.xamarin.com/guides/mac/getting_started/hello,_mac/

But i don't have a Cocoa App. I have a single page or master page app and etc. Ok, well. When I created these projects i cannot run I can not run them on my Mac. Maybe i don't have any component?

Repeating Task.Delay causes a large delay

$
0
0

I'm developing Xamarin.Mac(Cocoa) using C#. I want to develop application waiting seconds sometimes, so I developed waiting function using Task.Delay.
But repeating Task.Delay causes a large delay.

This is a test code for Cocoa.

using System;
using System.Threading.Tasks;
using System.Threading;
using AppKit;
using Foundation;

namespace TaskDelayTest
{
    public partial class ViewController : NSViewController
    {
        public ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
        }

        public override NSObject RepresentedObject
        {
            get
            {
                return base.RepresentedObject;
            }
            set
            {
                base.RepresentedObject = value;
            }
        }

        async partial void Execute(AppKit.NSButton sender)
        {
            while (true)
            {
                int millisecond = 1000;
                Console.WriteLine($"WaitTime : {millisecond}");
                var startDate = DateTime.Now;
                await Task.Delay(millisecond).ConfigureAwait(false);

                var endDate = DateTime.Now;
                var diff = (endDate - startDate);
                Console.WriteLine($"WaitEnd   : {endDate.ToString("yyyy/MM/dd HH:mm:ss.fff")}");
                Console.WriteLine($"DiffTime : {diff.TotalMilliseconds}");
            }
        }
    }
}

Console result:
.
.
.
(Repeating a lot of times)
.
.
.
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:25.784 DiffTime : 1000.192
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:26.784 DiffTime : 1000.193
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:27.785 DiffTime : 1000.232
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:28.785 DiffTime : 1000.462
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:39.785 DiffTime : 10999.643
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:42.259 DiffTime : 2473.116
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:43.582 DiffTime : 1322.505
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:44.582 DiffTime : 1000.173
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:45.582 DiffTime : 1000.147
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:48.973 DiffTime : 3389.941
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:49.973 DiffTime : 1000.186
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:50.973 DiffTime : 1000.186
WaitTime : 1000 WaitEnd : 2018/02/01 01:00:52.083 DiffTime : 1108.889
.
.
.

Sometimes very very delayed. This did not happen on Windows. It only occurred with Xamarin.Mac.
And I have to develop as asynchronous function because it's cocoa application. If I develop as not async function, it locks UI.

Badge for source list control in visual studio for mac

$
0
0

Hi,
i have two questions:
1) Does visual studio support badges for source list. I would like to show number of item in each category in a source list. I couldn't find any support on internet for it. I have .app project for mac os. I found lot of support in object c but i am unable to understand any examples of c# will be a great help.

2) how to expand the first row of source list and select the first child in xamarin.mac application.

Viewing all 1429 articles
Browse latest View live