Flex Conditional Compile Error - actionscript-3

I'm doing the following:
CONFIG::TEST{
rootURL = "myTestURL";
}
CONFIG::PROD{
rootURL = "myProdURL";
}
In compiler arguments I have this:
-locale en_US -define+=CONFIG::AIR,true -define+=CONFIG::WEB,false
-show-unused-type-selector-warnings=false
-define+=CONFIG::PROD,false -define+=CONFIG::TEST,true
But I'm getting errors for them both:
Access of undefined property PROD.
Access of undefined property TEST.
What is extremely odd is that this code works on my windows machine, but not on my mac. I've tried various things -- doing a clean checkout of code, cleaning the project, reinstalling Flash Builder. I also tried changing the order of the arguments, placing the last two in front of the selector warnings. That didn't help either.
Has anyone seen this before?

Try to set first -define=CONFIG::AIR,true without += or use -load-config+=configs.xml
<?xml version="1.0" encoding="utf-8"?>
<flex-config>
<compiler>
<define append="true">
<name>CONFIG::AIR</name>
<value>true</value>
</define>
...
</compiler>
</flex-config>

Related

PhpStorm unable to resolve symbol 'doctrine.orm.entity_manager'

When I open the services.xml in PhpStorm with Symfony Plugin enabled, it's able to resolve all the services, I can Ctrl+Click and go the Service Definition , except doctrine.orm.entity_manager.
It says unable to resolve symbol 'doctrine.orm.entity_manager'
Here is the services.xml file
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="example_manager" class="Vendor\XysBundle\Manager\ExampleManager">
<argument type="service" id="doctrine.orm.entity_manager" />
</service>
</services>
</container>
PhpStorm Details:
PhpStorm 2016.3.1
Build #PS-163.9735.1, built on December 6, 2016
JRE: 1.8.0_112-release-408-b2 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
appDevDebugProjectContainer.xml file exists in the app/cache directory .
How can I get get this working ?
I have the same issue. If you open up the vendor\doctrine\doctrine-bundle\Resources\config\orm.xml file where doctrine services are defined, you can see, there is no service with the id "doctrine.orm.entity_manager" but only "doctrine.orm.entity_manager.abstract"
The definition looks like:
<service id="doctrine.orm.entity_manager.abstract" class="%doctrine.orm.entity_manager.class%" abstract="true" />
As you can see the abstract attribute is set to true. This means this service can serve as a parent of other services, and when you define child services with this abstract parent you don't have to define the method calls or the parameters injected into the constructor for example, instead these definitions will be inherited from the parent.
If you investigate a bit deeper you will find that %doctrine.orm.entity_manager.class% is defined in the same file as a parameter that actually references to the Doctrine Entity Manager:
<parameter key="doctrine.orm.entity_manager.class">Doctrine\ORM\EntityManager</parameter>
So I guess we should use doctrine.orm.entity_manager.abstract, however doctrine.orm.entity_manager is recognised as well, although I don't know how.
For further explanation of abstract service definitions have a look at this Symfony doc page: https://symfony.com/doc/current/service_container/parent_services.html

CAstle Windsor: How to reference a second xml config file that is an embedded resource?

We have one xml configuration file that we use in production. We also have a little test app that has a couple of additional needs. What I'd like to do is create a second, testing-only xml config file that references the embedded production configuration file. Is there any way to do this?
I'm aware of the "include" element, but am not sure where in the file it is supposed to be placed--in the castle node? The components node?
I feel like the answer is here but I'm too dense to figure it out.
Thanks for any help you can provide.
UPDATE
This is how our production config file is set up:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<installers>
<!-- some installers-->
<installers>
<components>
<!--some components-->
<components>
<castle>
<Framework>
<OurCompany>
My most recent attempt at a non-production config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<OurCompany>
<Framework>
<castle>
<include uri="assembly://AssemblyContainingEmbeddedXml/MyEmbeddedConfig.xml" />
<components>
<!--components I only want registered with container when running in non-production environment-->
<components>
<castle>
<Framework>
<OurCompany>
The exception I get reads:
Configuration parser encountered Framework, but it was expecting to find installers, facilities or components. There might be either a typo on or you might have forgotten to nest it properly.
(In the actual message, "Framework," "installers," "facilities," and "components" are enclosed in angle brackets.)
The bottom of the page you reference has an example of loading from an embedded resourced:
IResource resource = new AssemblyResource("assembly://Acme.Crm.Data/Configuration/services.xml");
container = new WindsorContainer(new XmlInterpreter(resource));

'JSON' is null or not an object' error in classic ASP

I'm getting the error in the title --JSON is null or not an object.
I am inside a classic ASP page. My json2.js file is located in the same directory as this classic asp page that I'm in. So I have no idea why the server can't seem to recognize the JSON.parse() method.
My scripting language is JScript.
I noticed that in a different thread, using the json2.js library is the way to go. But I can't seem to get this to work. Is this a quirk? This should be very straightforward, no?
requestBody is a simple JSON object: [{"answer":"ok"},{"answer":"sunny"}]
Thanks!
<script language="javascript" runat="server" src="json2.js"></script>
<%
var jsonObject = JSON.parse(requestBody);
%>
Not sure, but the first thing I would do is check the permissions on json2.js. Use icacls.exe, and verify that the permissions on that file match the perms on the .ASP page itself. I do this:
%windir%\system32\icacls.exe json2.js /grant "NT AUTHORITY\IUSR:(RX)"
%windir%\system32\icacls.exe json2.js /grant "BUILTIN\IIS_IUSRS:(RX)"
Also - to help debug ASP you can fiddle with the ASP debugging settings in IIS Manager. Click "Send errors to client" to see the errors in the client browser window.
Alternatively, you can manually add this to web.config:
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
<asp scriptErrorSentToBrowser="false" />
</system.webServer>
</configuration>
On Vista/2008/Win7, you may also need to "unlock" the web.config stanza that permits this.
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/asp
This won't fix the "JSON not an object" problem, but it will give you better error messages when failures occur.
Should work, just made quick test case.
Things to try on your side:
Try to rename the included file to json2.asp and change to:
<script language="javascript" runat="server" src="json2.asp"></script>
There might be problem with the mime type and such stuff.
If no luck, leave the file renamed and try browsing directly to json2.asp with the browser, instead to your own page.
Try adding some debug code to the included file, and see if it's being executed.
If still no luck, please also specify what exact server you're using and what platform and maybe somebody will have fresh ideas.
The .NET Framework 3.5 has the JavaScriptSerializer class that can help in deserialization of a json object. You can also use third party libraries like JSON.NET.

How to override a configuration property?

I am trying to do both Release and Debug builds on .Net v4.0, where I have a MSBuild project file rather than a solution file. I want to use the same build project file, but just override the Configuration property switching between "Debug" and "Release".
When I execute as follows
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" /verbosity:Diagnostic
I get the following error
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(483,9):
error : The OutputPath property is not set for project
'buildinv.proj'. Please check to make sure that you have specified a
valid combination of Configuration and Platform for this project.
Configuration='Debug' Platform=''.
I can see that that the error is occurring in _CheckForInvalidConfigurationAndPlatform.
If I pass an OutputPath property it will however work
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj
/target:rebuild "/property:Configuration=Debug" "/property:OutputPath=."
Is this a known bug ? Where I need to override the Configuration property I am going to get forced to override the OutputPath property even though i do not wish to.
Thanks in advance.
In my project files OutputPath property is defined in the property groups specified for every Configuration & Platform. If you don't set correct Platform, OutputPath property is not set and your build will fail.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
Add Platform property into your command line:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;Platform=AnyCPU" /verbosity:Diagnostic
Add one of the following to your project file. The error means OutputPath environment variable is not getting it's value. By removing the "Condition=" from PropertyGroup, OutputPath will always be set for any platform or configuration, by default.
<PropertyGroup>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<OutputPath>$(DefaultOutputDirectory)</OutputPath>
</PropertyGroup>
If you don't want to modify the project file, you can also just specify the OutputPath for the build in your command:
c:\windows\microsoft.net\framework\v4.0.30319\msbuild.exe buildinv.proj /target:rebuild "/property:Configuration=Debug;OutputPath=C:\MyOutputPath" /verbosity:Diagnostic

Help with Castle Windsor XML configuration

I have the following three components defined in the Caste-Windsor XML configuration for my application:
<component id="StringFactory"
service="IStringFactory, MyApp"
type="DefaultStringFactory, MyApp"
lifestyle="singleton"
/>
<component id="TheString"
type="System.String"
factoryId="StringFactory"
factoryCreate="CreateString"
>
<parameters>
<name>SomeString</name>
</parameters>
</component>
<component id="TheTarget"
service="ITarget, MyApp"
type="TheTarget, MyApp"
lifestyle="transient"
>
<parameters>
<aString>${TheString}</aString>
</parameters>
</component>
And the following facility defined:
<facility id="factory.support"
type="Castle.Facilities.FactorySupport.FactorySupportFacility, Castle.MicroKernel"
/>
When I run the application and set a breakpoint in the constructor of the TheObject class, the value passed in as the aString parameter is "${TheString}" when I expect it to resolve to the value of the component with that name.
Also, I have a breakpoint in the StringFactory constructor and CreateString method, neither of which are hit. I know the configuration is being used as other components are resolving correctly.
What am I missing or doing wrong here?
UPDATE
In light of the huge tangient this topic has taken, I've refactored the code above to remove anything to do with connection strings. The original intent of this post was about injecting a property with the value returned from a method on another object. Somehow that point was lost in a discussion about why I'm using XML versus code-based configuration and if this is a good way to inject a connection string.
The above approach is far from an original idea and it was pulled from several other discussions on this topic and our requirements are what they are. I'd like help understanding why the configuration as it is in place (whether the right approach or not) isn't working as expected.
I did verify that the first two components are being instantiated correctly. When I call Container.Resolve("TheString"), I get the correct value back. For whatever reason, The parameter syntax is not working correctly.
Any ideas?
While not a definitive solution to what I need to do in my application, I believe I've figured out what is wrong with the code. Or at least I've found a way to make it work which hints at the original problem.
I replaced the String type for TheString with a custom class. That's it. Once I did that, everything worked fine.
My guess is that it has something to do with the fact that I was trying to use a ValueType (primitive) as a component. I guess Castle doesn't support it.
So, knowing that's the case, I can now move on to figuring out if this approach is really going to work or if we need to change direction.
UPDATE
For the sake of completeness, I thought I'd go ahead and explain what I did to solve my problem AND satisfy my requirements.
As before, I have access to my configuration settings through an IConfigurationService defined as:
<component id="ConfigurationService"
service="MyApp.IConfigurationService, MyApp"
type="MyApp.RuntimeConfigurationService, MyApp"
lifestyle="singleton"
/>
This is automatically injected into my (new) IConnectionFactory which is responsible for generating IDbConnection objects based on the connection strings defined in the application's configuration file. The factory is declared as:
<component id="ConnectionFactory"
service="MyApp.Factories.IConnectionFactory, MyApp"
type="MyApp.Factories.DefaultConnectionFactory, MyApp"
lifestyle="singleton"
/>
In order to resolve what connection is used by my repository, I declare each connection as a component using the ConnectionFactory to create each instance:
<component id="MyDbConnection"
type="System.Data.IDbConnection,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
factoryId="ConnectionFactory"
factoryCreate="CreateConnection"
lifestyle="transient"
>
<parameters>
<connectionStringName>MyDB</connectionStringName>
</parameters>
</component>
Notice the fully described reference to System.Data. I found this is necessary whenever referencing assemblies in the GAC.
Finally, my repository is defined as:
<component id="MyRepository"
service="MyApp.Repositories.IMyRepository, MyApp"
type="MyApp.Sql.SqlMyRepository, MyApp.Sql"
lifestyle="transient"
>
<parameters>
<connection>${MyDbConnection}</connection>
</parameters>
</component>
Now everything resolves correctly and I don't have ANY hard-coded strings compiled into my code. No connection string names, app setting keys or whatever. The app is completely reconfigurable from the XML files which is a requirement I must satisfy. Plus, other devs that will be working with the solution can manage the actual connection strings in the way they are used to. Win-win.
Hope this helps anyone else that runs into a similar scenario.
You don't really need XML registrations here, since you probably don't need to swap components or change the method used without recompiling. Writing a configurable app does not imply having to use XML registrations.
The problem with this particular XML registration you posted is that the connection string is a parameter, but it's treated like a service.
Doing this with code registrations is much easier, e.g.:
var container = new WindsorContainer();
container.Register(Component.For<IConfigurationService>().ImplementedBy<RuntimeConfigurationService>());
container.Register(Component.For<ITheRepository>().ImplementedBy<TheRepository>()
.LifeStyle.Transient
.DynamicParameters((k, d) => {
var cfg = k.Resolve<IConfigurationService>();
d["connectionString"] = cfg.GetConnectionString();
k.ReleaseComponent(cfg);
}));
Or if you don't want to depend on IConfigurationService, you could do something like:
container.Register(Component.For<ITheRepository>().ImplementedBy<TheRepository>()
.LifeStyle.Transient
.DependsOn(Property.ForKey("connectionString")
.Is(ConfigurationManager.ConnectionStrings[ConfigurationManager.AppSettings["connName"]].ConnectionString))