Using Images and Icons in WPF - c#

I am trying to use an Icon in my WPF application, and some images for other things, but I keep getting errors from the Designer View saying stuff like "path-x is not a valid resource or cannot be found." - where "path-x" is the path of whatever image I am trying to use.
If it were looking in the right place, I bet it'd find it ;)
BUT, then, it decided to not give me that error anymore. So, I went ahead and clicked Run (F5), to see my new Icon in the title bar. Only to be confronted with this beast:
"System.Windows.Markup.XamlParseException
occurred Message='Provide value on
'System.Windows.Baml2006.TypeConverterMarkupExtension'
threw an exception.' Line number '5'
and line position '50'.
Source=PresentationFramework
LineNumber=5 LinePosition=50
StackTrace:
at System.Windows.Markup.XamlReader.RewrapException(Exception
e, IXamlLineInfo lineInfo, Uri
baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader
xamlReader, IXamlObjectWriterFactory
writerFactory, Boolean
skipJournaledProperties, Object
rootObject, XamlObjectWriterSettings
settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader
xamlReader, Boolean
skipJournaledProperties, Object
rootObject, XamlAccessLevel
accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream
stream, ParserContext parserContext,
Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object
component, Uri resourceLocator)
at One_Stop_Management.MainWindow.InitializeComponent()
in c:\Users\Jason\Documents\Visual
Studio 2010\Projects\One Stop
Management\One Stop
Management\MainWindow.xaml:line 1
at One_Stop_Management.MainWindow..ctor()
in C:\Users\Jason\Documents\Visual
Studio 2010\Projects\One Stop
Management\One Stop
Management\MainWindow.xaml.cs:line 25
InnerException: System.IO.IOException
Message=Cannot locate resource 'images/favicon.ico'.
Source=PresentationFramework
StackTrace:
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode
mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode
mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri
uri, Stream stream, BitmapCacheOption
cacheOption, Guid& clsId, Boolean&
isOriginalWritable, Stream& uriStream,
UnmanagedMemoryStream&
unmanagedMemoryStream, SafeFileHandle&
safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri
baseUri, Uri uri, Stream stream,
BitmapCreateOptions createOptions,
BitmapCacheOption cacheOption,
RequestCachePolicy uriCachePolicy,
Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri
baseUri, Uri uri, Stream stream,
BitmapCreateOptions createOptions,
BitmapCacheOption cacheOption,
RequestCachePolicy uriCachePolicy)
at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext
context, CultureInfo culture, Object
value)
at System.Windows.Baml2006.TypeConverterMarkupExtension.ProvideValue(IServiceProvider
serviceProvider)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension
me, IServiceProvider serviceProvider)
InnerException: "
Why is this thing giving me attitude? I'm just trying to insert an image...
Updates
Here is the XAML that was produced for the icon when I tried to add the Icon using the Properties Pane:
<Fluent:RibbonWindow x:Class="One_Stop_Management.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
Title="One Stop Management" Height="727" Width="1208" Icon="Resources\favicon.ico">
Latest Update
I can't even add an icon using the properties pane, below is the error it gives me.

Make sure the target is a resource. Then do something like this:
Icon="/MobilWPF;component/Resources/Images/MobileIcon.ico"
where MobilWPF is your namespace, or maybe you're project name? I forget my project name and my namespace are the same.

I've discovered that VS2008 sometimes causes problems like this when you add new resources and then rebuild the project. I've found if you clean the build and then rebuild from scratch the problem disappears. Looks like a VS2008 bug to me.

I fixed this same issue by setting these properties for the image:
Build Action = Content
Copy to Output Directory = Copy always

The exception, if you read through it, says the same thing:
InnerException: System.IO.IOException Message=Cannot locate resource 'images/favicon.ico'.
This is probably because the Images/favicon.ico icon image is not setup correctly. Make sure that it's Build Action is set to "Resource", and that it's in the project under the "Images" folder.

The answer seems to depend on where/how you store the icon. I was trying to do something similar to #iterationx's answer but it didn't work for me, and this is what I finished up with. I'm using VS 2010.
I added the icon as a resource via the project's properties page, under Resources, Add Resource (dropdown), Add existing file. Then I just used the file name in the Icon property:
Icon="my_icon.ico"

I recall a similar situation where my application was crashing, and I eventually tracked it down to an .ico error.
If you're using icons and Windows XP, XP does not support the 256x256 icons. You may need to open the icon in an editor, such as IcoFx, and delete the 256x256 icon.

Setting BuildAction to Resource in resource Properties solved this problem.
Greets

I'm sorry I can't be more helpful. On reading your question at first I thought it'd be just a type mismatch, like where you were specifying a string when it was meant to be an image. The issue seems to be one that has multiple possible resolutions. Instead of listing them all I'll just link you to the Microsoft Connect page that has them on it.

I had this same problem and found that if your project has a space in the name, it won't read the image files correctly. Hope that helps.

use Icon=".\Images\test.ico" this got me working

Related

Unable to load shared library 'python37' or one of its dependencies

I am quite new to dotnet and Keras.NET, and I was trying to set it up on a goorm.io container. After installing the prerequisites (adding $HOME/.keras/keras.json for Tensorflow backend and pip install numpy), and then adding Keras.NET, I tried to run the XOR sample code, but ran into an error.
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'python37' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libpython37: cannot open shared object file: No such file or directory
at Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.Initialize(Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(IEnumerable1 args, Boolean setSysArgv, Boolean initSigs) at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs) at Python.Runtime.PythonEngine.Initialize() at Numpy.np.InstallAndImport(Boolean force) at Numpy.np.<>c.<.cctor>b__599_0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue()
at System.Lazy1.get_Value() at Numpy.np.get_self() at Numpy.np.get_float32() at Numpy.DtypeExtensions.GetDtype(Object obj) at Numpy.np.array[T](T[,] object, Dtype dtype, Nullable1 copy, String order, Nullable1 subok, Nullable1 ndmin)
at Proj.Program.Main(String[] args) in /workspace/XOR/Proj/Program.cs:line 14
I do not know how to share with the python37 directory. If someone could direct me in the right direction, it would be much appreciated. By the way, I am using Linux if that helps.
Thanks

NReco FFPMegConverter: The path is not of a legal form

I'm using the NReco FFMPegConverter, and when I try to get a thumbnail, I get the error:
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.File.InternalGetLastWriteTimeUtc(String path, Boolean checkHost)
at NReco.VideoConverter.FFMpegConverter.EnsureFFMpegLibs()
at NReco.VideoConverter.FFMpegConverter.ExtractFFmpeg()
Here is the line of code where I'm getting my error.
var filep = domainVideoFile.AbsolutePath;
_fFMpegConverter.GetVideoThumbnail(filep, tempfileName);
In the above example, filep = "C:\Users\me_000\Downloads\GRoma\G.mp4"
and tempFileName = "C:\Users\me_000\Desktop\f480b6c0.jpeg"when copied directly from the Locals view in Debug mode.
There is another thread citing this issue on SO and the stated solution is to set the FFMPegToolPath property.
fFMpegConverter.FFMpegToolPath = _thumbPathManager.GetFFMPegPath;
I've tried that and various versions of it and I still get the error. I'm using the version of 1.1.2.0 if that helps.
The error pops up no matter what I do with respect to calling FFMpegToolPath, ExtractFFmpeg and what not.
Any help is greatly appreciated.
The problem was very insidious but I figured out what was happening.
I'm using Fody.Costura to merge my DLL resources. This works for all the other DLLS, but the NReco DLLs don't take kindly to being merged. I guess somewhere along the way this is causing file pathing issues since the DLL doesn't exist as a standalone file.

TFS Git build breaks after updating build definition

Our TFS build has broken following updating the XAML build definition. Changes included modifying the template and a few parameters. The trace is below
TF215097: An error occurred while initializing a build for build definition [REDACTED]:
Exception Message: Cannot set unknown member 'Microsoft.TeamFoundation.Build.Activities.Git.GitPull.CheckoutSubmodules'. (type XamlObjectWriterException)
Exception Stack Trace: at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
at System.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
at System.Activities.XamlIntegration.FuncFactory`1.Evaluate()
at System.Activities.DynamicActivity.OnInternalCacheMetadata(Boolean createEmptyBindings)
at System.Activities.Activity.InternalCacheMetadata(Boolean createEmptyBindings, IList`1& validationErrors)
at System.Activities.ActivityUtilities.ProcessActivity(ChildActivity childActivity, ChildActivity& nextActivity, Stack`1& activitiesRemaining, ActivityCallStack parentChain, IList`1& validationErrors, ProcessActivityTreeOptions options, ProcessActivityCallback callback)
at System.Activities.ActivityUtilities.ProcessActivityTreeCore(ChildActivity currentActivity, ActivityCallStack parentChain, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.ActivityUtilities.CacheRootMetadata(Activity activity, LocationReferenceEnvironment hostEnvironment, ProcessActivityTreeOptions options, ProcessActivityCallback callback, IList`1& validationErrors)
at System.Activities.Validation.ActivityValidationServices.InternalActivityValidationServices.InternalValidate()
at Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.ValidateWorkflow(Activity activity, ValidationSettings validationSettings)
at Microsoft.TeamFoundation.Build.Hosting.BuildProcessCache.LoadFromXaml(String workflowXaml, TextExpressionImports textExpressionImports)
at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
The build fails in the first few seconds as this is the process that is trying to retrieve the source. However, I cannot come to any conclusions as to why this error is happening. A Google search doesn't bring up anything useful.
TFS version 2013
Has anyone encountered this error and if so how did you fix it?
If I need to provide more information please ask.
When you modify the Build process template and therefore it’s no longer in sync with the build definition you may get TF215097 error.
#jessehouwing's suspicion makes sense. I can't find too many articles to elaborate this issue, but in this MSND documentation mentions, if you want to edit a custom template, You must use only Visual Studio 2013 to edit your build process templates of TFS 2013.

Does WPF resent cat images? or: Why can I reference one, but not the other image from the very same folder?

I am developing a WPF application and at some point, I am loading an image. That image is a .png file, residing in a folder within my Visual Studio project. The build action of that file is set to Resource. This particular image is not alone in that; there are several other PNGs in that very same folder, with the very same build action. On the XAML side, the ImageSource-Property of the ImageBrush-Element is bound to a Uri-Property of the viewmodel.
And now for the weird part; this is the line of code that sets the Uri-Property of my viewmodel:
ViewModel.Image = new Uri(#"/Images/RandomIcon.png", UriKind.Relative);
But if I change the Uri to point to the carefully googled cat image I chose for testing purposes, I get an exception stack in the debug console, telling me the image could not be found:
ViewModel.Image = new Uri(#"/Images/testcat.png", UriKind.Relative);
Again, the images reside in the same folder and their build action property is Resource. The only notable difference I can think of is that the other images are icons, so significantly smaller than my testcat (2.5KB vs 140KB).
The exception as shown on the debug console:
System.Windows.Data Error: 6 : 'TargetDefaultValueConverter' converter failed to convert value '/Images/testcat.png' (type 'Uri'); fallback value will be used, if available. BindingExpression:Path=Image; DataItem='ViewModel' (HashCode=55110660); target element is 'ImageBrush' (HashCode=51947944); target property is 'ImageSource' (type 'ImageSource') IOException:'System.IO.IOException: The Resource "images/testcat.png" cannot be found.
at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.get_ContentType()
at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle)
at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at MS.Internal.Data.DefaultValueConverter.ConvertHelper(Object o, Type destinationType, DependencyObject targetElement, CultureInfo culture, Boolean isForward)
at MS.Internal.Data.TargetDefaultValueConverter.Convert(Object o, Type type, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertHelper(IValueConverter converter, Object value, Type targetType, Object parameter, CultureInfo culture)'
Which inspires my question: Does WPF resent cat images? or: Why can I reference one, but not the other image?
EDIT:
After having tried with a dog image, I can safely say that WPF does not discriminate against cats. On a more serious note, I was able to resolve my issues with help of the accepted answer, but I still don't know why it wouldn't work before.
It's difficult to determine exactly what you have done wrong from the tiny bits of information that you have provided here. However, that shouldn't matter so much because displaying Images in WPF is simple. My first tip would be to not use the Uri class at all and simply use string representations of the file paths instead.
I would also recommend that you get used to the Pack URIs in WPF used to reference files... take this example:
<Image Source="{Binding DisplayedImagePath}" />
...
public string DisplayedImagePath
{
get { return #"C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg"; }
}
Although (as you appear to have done) you really should add your images to a folder named Images in the root of your project and set their Build Action to Resource in the Properties Window in Visual Studio... you could then access them using this format:
public string DisplayedImagePath
{
get { return "/AssemblyName;component/Images/ImageName.png"; }
}
In .NET 4, the above Image.Source values would work. However, Microsoft made some horrible changes in .NET 4.5 that broke many different things and so in .NET 4.5, you'd need to use the full pack path like this:
<Image Source="pack://application:,,,/AssemblyName;component/Images/ImageName.png">

Sharing Violation on path in Adcolony

I have a completed game working properly in Android and is published on Play store already. Now I wanted to submit it on iTunes. As soon as I started building the same project for iOS, I got this strange Error -
IOException: Sharing violation on path /Users/abhi/Projects/Unity/XCode Proj/Hammer Inc/Unity-iPhone.xcodeproj/project.pbxproj
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:320)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.File.OpenRead (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:363)
System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/StreamReader.cs:167)
System.IO.StreamReader..ctor (System.String path)
(wrapper remoting-invoke-with-check) System.IO.StreamReader:.ctor (string)
System.IO.File.OpenText (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:368)
System.IO.File.ReadAllLines (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:560)
AdColonyPostProcessBuild.updateXcodeProject (System.String pbxProjectFilePath, System.String thirdPartyFrameworkDirectoryPath, .Framework[] frameworksToAdd) (at Assets/Editor/AdColonyPostProcessBuild.cs:356)
AdColonyPostProcessBuild.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Editor/AdColonyPostProcessBuild.cs:340)
UnityEditor.HostView:OnGUI()
I got this error, after I was having some trouble with GPG Plugin and as mentioned here, I deleted the files and folders related to Google Play gaming, since I planned to use Game Center in iOS.
I am currently using Native-X, Adcolony, Revmob in the same project (I know that's too much, but that was due to an experiment on choosing proper network). I am not sure which of the plugin is causing conflicts.
I tried removing the AdColonyPostProcessBuild.cs file, but it gave the following error -
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (.TKey
key) (at
/Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/
corlib/System.Collections.Generic/Dictionary.cs:150)
UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:49)
UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:53)
UnityEditor.XCodeEditor.PBXParser.GUIDComment (System.String guid,
System.Text.StringBuilder builder) (at Assets/Editor/iOS/PBX
Editor/PBXParser.cs:218)
UnityEditor.XCodeEditor.PBXParser.SerializeString (System.String
aString, System.Text.StringBuilder builder, Boolean useQuotes, Boolean
readable) (at Assets/Editor/iOS/PBX Editor/PBXParser.cs:546)
UnityEditor.XCodeEditor.PBXParser.SerializeDictionary
(System.Collections.Generic.Dictionary`2 dictionary,
System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:481)
UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value,
System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:439)
UnityEditor.XCodeEditor.PBXParser.SerializeDictionary
(System.Collections.Generic.Dictionary`2 dictionary,
System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:489)
UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value,
System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:439)
UnityEditor.XCodeEditor.PBXParser.Encode
(UnityEditor.XCodeEditor.PBXDictionary pbxData, Boolean readable) (at
Assets/Editor/iOS/PBX Editor/PBXParser.cs:177)
UnityEditor.XCodeEditor.XCProject.CreateNewProject
(UnityEditor.XCodeEditor.PBXDictionary result, System.String path) (at
Assets/Editor/iOS/XCProject.cs:620)
UnityEditor.XCodeEditor.XCProject.Save () (at
Assets/Editor/iOS/XCProject.cs:645) XCodePostProcess.OnPostProcessBuild
(BuildTarget target, System.String path) (at
Assets/Editor/iOS/XCodePostProcess.cs:35) UnityEditor.HostView:OnGUI()
Did anyone faced this issue before and found any solution? I don't want to delete every SDK from the project and start building it again.
I see you have a couple of issues. That sounds like a bummer. But, I would definitely like to help.
What's Happening:
Regarding the first error that you've provided it looks like it's having an issue reading the pbxproj file that Unity creates for the iOS build process.
Typically, when building for iOS, Unity will create a .pbxproj file in conjunction with the rest of the XCode items and then place that in the target build directory you specify. After that it triggers any post process build logic that has been hooked in by the developer.
AdColony's AdColonyPostProcessBuild.cs file is generally intended to be run last out of the post process build logic, because we rely on parsing the .pbxproj file itself, and then adding the information in line by line. The reason we prefer to do this last is because there exist current solutions to this problem that don't necessarily facilitate all the configurations we need, but other developers use it.
The first error looks like it's an access violation issue with the AdColonyPostProcessBuild not being able to access the .pbxproj file, so it can read in all of the lines. Because of this it's throwing an IOException seen here:
IOException: Sharing violation on path /Users/abhi/Projects/Unity/XCode Proj/Hammer Inc/Unity-iPhone.xcodeproj/project.pbxproj
and
System.IO.File.ReadAllLines (System.String path) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:560)
AdColonyPostProcessBuild.updateXcodeProject (System.String pbxProjectFilePath, System.String thirdPartyFrameworkDirectoryPath, .Framework[] frameworksToAdd) (at Assets/Editor/AdColonyPostProcessBuild.cs:356)
This brings me to my next point.
The second error that you've listed is something that arises out of an alternative post process build logic called "XCode Editor For Unity".
You can find it here:
https://github.com/dcariola/XCodeEditor-for-Unity
This solution is a C# implementation of a solution known as mod_pbxproj, and other developers have opted for this solution. However, when using it in conjunction with AdColony it will typically break if the XCode Editor For Unity is performed after the AdColonyPostProcessBuild.cs is run.
This is because some of the information used for the XCode Editor For Unity parsing has been duplicated and is being read in twice, when AdColonyPostProcessBuild.cs is run.
AdColony has configured our post process logic to run last, relying on the ability to parse the information after the XCode Editor For Unity has been run.
The Suggested Solution
The information you've provided has been very helpful, but it's hard to say for certain why these may be arising.
What will facilitate this process is if you could list any other plug-ins you're using that have a post process build applied for iOS builds AND if you can also provide any indications of their priority or order of occurrence on build.
Following that, the line numbers I see in your error output appear a bit inconsistent with the current version of the AdColonyPostProcessBuild.cs file in our current available package.
I would first suggest going to this link, downloading the current package, and re-importing the AdColonyPostProcessBuild.cs
https://github.com/AdColony/AdColony-Unity-SDK
If that doesn't resolve the issue, I would then open up the AdColonyPostProcessBuild.cs file and change its priority to be lower, preferably to be the last post process build item to run. You can do this by changing the number '200' on line 302, to a great number, like '1000'.
If this doesn't resolve your problem I will need to know more about your environment configuration like other plug-ins you are using, and deviations you've made from the default AdColonyPostProcessBuild.cs file.
Regards!
AdColony Support
This problem arose for me because I was using the Facebook SDK with Adcolony's SDK. The Facebook code leaves a streamReader open which produces the error when the Adcolony script is run. Change lines in Assets\Facebook\Editor\iOS\third_party\XCodeEditor-for-Unity\XCProject.cs
from (lines 76-77):
projectFileInfo = new FileInfo(Path.Combine(this.filePath, "project.pbxproj"));
string contents = projectFileInfo.OpenText().ReadToEnd();
to:
projectFileInfo = new FileInfo(Path.Combine(this.filePath, "project.pbxproj"));
StreamReader sr = projectFileInfo.OpenText();
string contents = sr.ReadToEnd();
sr.Close();
(credit to the answer here: "IOException: Sharing violation on path" on building a Unity project on Mac OS X with Facebook Unity SDK 5.1)

Categories

Resources